Here you can find the source of equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
Parameter | Description |
---|---|
left | The left array to compare |
offsetLeft | The offset into the array. Must be positive |
right | The right array to compare |
offsetRight | the offset into the right array. Must be positive |
length | The length of the section of the array to compare |
public static boolean equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
//package com.java2s; /** // w ww . j a v a 2 s .c o m * Returns an array size >= minTargetSize, generally * over-allocating exponentially to achieve amortized * linear-time cost as the array grows. * * NOTE: this was originally borrowed from Python 2.4.2 * listobject.c sources (attribution in LICENSE.txt), but * has now been substantially changed based on * discussions from java-dev thread with subject "Dynamic * array reallocation algorithms", started on Jan 12 * 2010. * * @param minTargetSize Minimum required value to be returned. * @param bytesPerElement Bytes used by each element of * the array. See constants in {@link JvmUtil}. * */ public class Main { /** * See if two array slices are the same. * * @param left The left array to compare * @param offsetLeft The offset into the array. Must be positive * @param right The right array to compare * @param offsetRight the offset into the right array. Must be positive * @param length The length of the section of the array to compare * @return true if the two arrays, starting at their respective offsets, are equal * * @see java.util.Arrays#equals(char[], char[]) */ public static boolean equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length) { if ((offsetLeft + length <= left.length) && (offsetRight + length <= right.length)) { for (int i = 0; i < length; i++) { if (left[offsetLeft + i] != right[offsetRight + i]) { return false; } } return true; } return false; } /** * See if two array slices are the same. * * @param left The left array to compare * @param offsetLeft The offset into the array. Must be positive * @param right The right array to compare * @param offsetRight the offset into the right array. Must be positive * @param length The length of the section of the array to compare * @return true if the two arrays, starting at their respective offsets, are equal * * @see java.util.Arrays#equals(byte[], byte[]) */ public static boolean equals(byte[] left, int offsetLeft, byte[] right, int offsetRight, int length) { if ((offsetLeft + length <= left.length) && (offsetRight + length <= right.length)) { for (int i = 0; i < length; i++) { if (left[offsetLeft + i] != right[offsetRight + i]) { return false; } } return true; } return false; } /** * See if two array slices are the same. * * @param left The left array to compare * @param offsetLeft The offset into the array. Must be positive * @param right The right array to compare * @param offsetRight the offset into the right array. Must be positive * @param length The length of the section of the array to compare * @return true if the two arrays, starting at their respective offsets, are equal * * @see java.util.Arrays#equals(char[], char[]) */ public static boolean equals(int[] left, int offsetLeft, int[] right, int offsetRight, int length) { if ((offsetLeft + length <= left.length) && (offsetRight + length <= right.length)) { for (int i = 0; i < length; i++) { if (left[offsetLeft + i] != right[offsetRight + i]) { return false; } } return true; } return false; } }