public static boolean sliceEquals()

in mr/src/main/java/org/elasticsearch/hadoop/util/ArrayUtils.java [62:88]


    public static boolean sliceEquals(byte[] a, int offa, int lena, byte[] b, int offb, int lenb) {
        if (a==b)
            return true;
        if (a==null || b==null)
            return false;

        if (lena > a.length || lenb > b.length) {
            throw new ArrayIndexOutOfBoundsException("Given length is greater than array length");
        }

        if (offa >= a.length || offb >= b.length) {
            throw new ArrayIndexOutOfBoundsException("Given offset is is out of bounds");
        }

        if (offa + lena > a.length || offb + lenb > b.length) {
            throw new ArrayIndexOutOfBoundsException("Given offset and length is out of array bounds");
        }

        if (lenb != lena)
            return false;

        for (int i=0; i<lena; i++)
            if (a[offa + i] != b[offb + i])
                return false;

        return true;
    }