Java Utililty Methods Array Compare

List of utility methods to do Array Compare

Description

The list of methods to do Array Compare are organized into topic(s).

Method

bytearrayCompare(byte src[], short srcOff, byte dest[], short destOff, short length)
Compares an array from the specified source array, beginning at the specified position, with the specified position of the destination array from left to right.
if (length < 0) {
    throw new ArrayIndexOutOfBoundsException();
if (length != 0) {
    byte tester = src[(srcOff + length) - 1];
    tester = dest[(destOff + length) - 1];
for (short i = 0; i < length; i++) {
...
booleanarrayCompare(byte[] a, byte[] a2)
Returns true if the two specified arrays of bytes are equal to one another.
if (a == a2)
    return true;
if (a == null || a2 == null)
    return false;
int length = a.length;
if (a2.length != length)
    return false;
for (int i = 0; i < length; i++)
...
booleanarrayCompare(byte[] a1, byte[] a2)
Compares two byte arrays
if (a1.length != a2.length)
    return false;
for (int i = 0; i < a1.length; i++)
    if (a1[i] != a2[i])
        return false;
return true;
booleanarrayCompare(byte[] b1, byte[] b2)
A "safe" array comparison that is not vulnerable to side-channel "timing attacks".
if (b1 == b2) {
    return true;
if (b1 == null || b2 == null) {
    return (b1 == b2);
if (b1.length != b2.length) {
    return false;
...
intarrayCompare(final T[] a, final T[] b)
array Compare
if (a == b) {
    return 0;
if (a == null && b != null) {
    return -1;
if (b == null && a != null) {
    return 1;
...
intarrayCompare(int[] arr1, int[] arr2)
array Compare
int result = 2;
boolean done = false;
if (arr1.length != arr2.length) {
    done = true;
int i = 0;
while (!done) {
    if (arr1[i] > arr2[i]) {
...
intarrayCompareLex(byte[] a, byte[] b)
array Compare Lex
return arrayCompareLex(a, 0, a.length, b, 0, b.length);
booleanarrayContentsEq(Object[] a1, Object[] a2)
array Contents Eq
if (a1 == null) {
    return a2 == null || a2.length == 0;
if (a2 == null) {
    return a1.length == 0;
if (a1.length != a2.length) {
    return false;
...
boolean[]createStainMask(float[] redOD, float[] greenOD, float[] blueOD, double stainThreshold, boolean excludeGray, boolean excludeUncommonColors, boolean[] mask)
create Stain Mask
if (mask == null) {
    mask = new boolean[redOD.length];
    Arrays.fill(mask, true);
double gray = 1 / Math.sqrt(3);
double grayThreshold = Math.cos(0.2);
for (int i = 0; i < mask.length; i++) {
    double r = redOD[i];
...
StringgetLongestCommonSubsequence(int[] a, int[] b)
get Longest Common Subsequence
String result = "";
int[][] LCS = new int[a.length + 1][b.length + 1];
String[][] solution = new String[a.length + 1][b.length + 1];
for (int i = 0; i <= b.length; i++) {
    LCS[0][i] = 0;
    solution[0][i] = "0";
for (int i = 0; i <= a.length; i++) {
...