Class ArrayUtil


  • public final class ArrayUtil
    extends Object
    Common operations which need to be performed on arrays in combinatorial test input generation.
    • Method Detail

      • exclude

        public static int[] exclude​(int[] elements,
                                    int[] excludedElements)
        Creates an array with the same order and elements as the original, except the excluded ones. For example, if elements is [0, 5, 3, 2, 5, 2], and excluded elements is [5, 6], then [0, 3, 2, 2] is the result.
        Parameters:
        elements - all elements. Must not be null
        excludedElements - the ones which are be excluded (duplicates don't matter). Most not be null
        Returns:
        all elements except the ones that shall be excluded
      • contains

        public static boolean contains​(int[] elements,
                                       int element)
        Checks whether the given element appears anywhere in the given array.
        Parameters:
        elements - all elements which are searched. Must not be null
        element - the element for which is searched
        Returns:
        whether the given element appears in the given elements at any arbitrary index
      • containsAll

        public static boolean containsAll​(int[] elements,
                                          int[] otherElements)
        Checks whether all otherElement appear anywhere in the given elements.
        Parameters:
        elements - all elements which are searched. Must not be null
        otherElements - all elements which must appear in elements
        Returns:
        whether the otherElements appear in the given elements at any arbitrary indices
      • indexOf

        public static OptionalInt indexOf​(int[] elements,
                                          int element)
        Parameters:
        elements - all elements building the search space.
        element - element that needs to be found in the search space.
        Returns:
        index of element in search space
      • containsDuplicates

        public static boolean containsDuplicates​(int[] elements)
        Parameters:
        elements - elements that are checked for duplicates.
        Returns:
        true iff elements contain duplicates.