Here you can find the source of equalsIgnoreSequence(final T[] array1, final T[] array2)
public static <T> boolean equalsIgnoreSequence(final T[] array1, final T[] array2)
//package com.java2s; /*/*from w ww . j a va 2s .c o m*/ * Copyright 2004-2012 the Seasar Foundation and the Others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ import java.util.Arrays; public class Main { public static <T> boolean equalsIgnoreSequence(final T[] array1, final T[] array2) { if (array1 == null && array2 == null) { return true; } else if (array1 == null || array2 == null) { return false; } if (array1.length != array2.length) { return false; } final T[] copyOfArray2 = Arrays.copyOf(array2, array2.length); for (int i = 0; i < array1.length; i++) { final T o1 = array1[i]; final int j = indexOf(copyOfArray2, o1, i); if (j == -1) { return false; } if (i != j) { final T o2 = copyOfArray2[i]; copyOfArray2[i] = array2[j]; copyOfArray2[j] = o2; } } return true; } public static <T> int indexOf(final T[] array, final T obj) { return indexOf(array, obj, 0); } public static <T> int indexOf(final T[] array, final T obj, final int fromIndex) { if (array != null) { for (int i = fromIndex; i < array.length; ++i) { final Object o = array[i]; if (o != null) { if (o.equals(obj)) { return i; } } else if (obj == null) { return i; } } } return -1; } public static int indexOf(final boolean[] array, final boolean value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final byte[] array, final byte value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final short[] array, final short value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final int[] array, final int value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final long[] array, final long value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final float[] array, final float value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final double[] array, final double value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } public static int indexOf(final char[] array, final char value) { if (array != null) { for (int i = 0; i < array.length; ++i) { if (array[i] == value) { return i; } } } return -1; } }