Java Array Region Match arrayRegionsEqual(boolean[] a, int aoff, int alen, boolean[] b, int boff, int blen)

Here you can find the source of arrayRegionsEqual(boolean[] a, int aoff, int alen, boolean[] b, int boff, int blen)

Description

array Regions Equal

License

Open Source License

Declaration

public static boolean arrayRegionsEqual(boolean[] a, int aoff, int alen, boolean[] b, int boff, int blen) 

Method Source Code

//package com.java2s;
/*-//  w  w  w  .j  a  va  2s . c o  m
 * Copyright (C) 2006-2007 Erik Larsson
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static boolean arrayRegionsEqual(boolean[] a, int aoff, int alen, boolean[] b, int boff, int blen) {
        if (alen != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (a[aoff + i] != b[boff + i])
                    return false;
            return true;
        }
    }

    public static boolean arrayRegionsEqual(byte[] a, int aoff, int alen, byte[] b, int boff, int blen) {
        if (a.length != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (a[aoff + i] != b[boff + i])
                    return false;
            return true;
        }
    }

    public static boolean arrayRegionsEqual(char[] a, int aoff, int alen, char[] b, int boff, int blen) {
        if (alen != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (a[aoff + i] != b[boff + i])
                    return false;
            return true;
        }
    }

    public static boolean arrayRegionsEqual(short[] a, int aoff, int alen, short[] b, int boff, int blen) {
        if (alen != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (a[aoff + i] != b[boff + i])
                    return false;
            return true;
        }
    }

    public static boolean arrayRegionsEqual(int[] a, int aoff, int alen, int[] b, int boff, int blen) {
        if (alen != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (a[aoff + i] != b[boff + i])
                    return false;
            return true;
        }
    }

    public static boolean arrayRegionsEqual(long[] a, int aoff, int alen, long[] b, int boff, int blen) {
        if (alen != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (a[aoff + i] != b[boff + i])
                    return false;
            return true;
        }
    }

    public static boolean arrayRegionsEqual(Object[] a, int aoff, int alen, Object[] b, int boff, int blen) {
        if (alen != blen)
            return false;
        else {
            for (int i = 0; i < alen; ++i)
                if (!a[aoff + i].equals(b[boff + i]))
                    return false;
            return true;
        }
    }
}

Related

  1. arrayRegionMatches(char[] source, int sourceStart, char[] target, int targetStart, int len)
  2. arrayRegionMatches(Object[] source, int sourceStart, Object[] target, int targetStart, int len)
  3. arrayRegionMatches(Object[] source, int sourceStart, Object[] target, int targetStart, int len)