Class ArrayUtil


  • public final class ArrayUtil
    extends Object
    • Method Detail

      • equalsIgnorePosition

        public static boolean equalsIgnorePosition​(Object[] arr1,
                                                   Object[] arr2)
        Compare two arrays regardless of the position of the elements in the arrays. The complex handling with temporary flags is necessary due to the possibility of having multiple occurrences of the same element in the arrays. In this case both arrays have to contain the exactly same amount of those elements. This is only suited for smaller arrays (e.g. count < 100) since the algorithm uses a product of both arrays. If one likes to use this for larger arrays, we'd have to use hashes.
        Parameters:
        arr1 -
        arr2 -
        Returns:
      • asSet

        public static <T> Set<T> asSet​(T... items)