Class ArraysPlume

java.lang.Object
org.plumelib.util.ArraysPlume

public final class ArraysPlume extends Object
Utilities for manipulating arrays. This complements Arrays.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).
    static final class 
    Compare two arrays lexically (element-by-element).
    static final class 
    Compare two arrays lexically (element-by-element).
    static final class 
    Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).
    static final class 
    Compare two arrays lexically (element-by-element).
    static final class 
    Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).
    static final class 
    Compare two arrays lexically (element-by-element).
    static final class 
    Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).
    static final class 
    Compare two arrays lexically (element-by-element).
    static final class 
    Compare two arrays lexically (element-by-element).
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    allNull(@PolyNull Object[] a)
    Returns true if all elements of a are null.
    static boolean
    allNull(List<?> a)
    Returns true if all elements of a are null.
    static boolean
    anyNull(@PolyNull @PolySigned Object[] a)
    Returns true if a contains null.
    static boolean
    anyNull(List<? extends @Nullable Object> a)
    Returns true if a contains null.
    static <T> T[]
    append(T[] array, T lastElt)
    Concatenates an array and an element into a new array.
    static boolean[]
    concat(boolean @Nullable [] a, boolean @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static byte[]
    concat(byte @Nullable [] a, byte @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static char[]
    concat(char @Nullable [] a, char @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static double[]
    concat(double @Nullable [] a, double @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static float[]
    concat(float @Nullable [] a, float @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static int[]
    concat(int @Nullable [] a, int @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static long[]
    concat(long @Nullable [] a, long @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static short[]
    concat(short @Nullable [] a, short @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static @PolyInterned @PolyNull String[]
    concat(@PolyInterned @PolyNull String @Nullable [] a, @PolyInterned @PolyNull String @Nullable [] b)
    Returns an array that contains all the elements of both argument arrays, in order.
    static <T extends @Nullable Object>
    T[]
    concat(@Nullable List<T> a, @Nullable List<T> b)
    Returns an array that contains all the elements of both arguments, in order.
    static <T extends @Nullable Object>
    T[]
    concat(@Nullable List<T> a, T @Nullable [] b)
    Returns an array that contains all the elements of both arguments, in order.
    static <T extends @Nullable Object>
    T[]
    concat(T @Nullable [] a, @Nullable List<T> b)
    Returns an array that contains all the elements of both arguments, in order.
    static <T extends @Nullable Object>
    T[]
    concat(T @Nullable [] a, T @Nullable [] b)
    Returns an array that contains all the elements of both arguments, in order.
    static <T> T[]
    concatenate(T[] array1, T... array2)
    Concatenates two arrays.
    static int
    elementRange(int[] a)
    Returns the difference between the smallest and largest array elements.
    static long
    elementRange(long[] a)
    Returns the difference between the smallest and largest array elements.
    static int @SameLen("#1") []
    fnCompose(@org.checkerframework.checker.index.qual.IndexFor({"#2"}) int[] a, int[] b)
    Returns the composition of the given two functions, all of which are represented as arrays.
    static int[]
    fnIdentity(@org.checkerframework.checker.index.qual.NonNegative int length)
    Returns an array [0..length).
    static int[]
    fnInverse(int[] a, @org.checkerframework.checker.index.qual.NonNegative int arange)
    Returns the inverse of the given function, which is represented as an array.
    static int[]
    Requires that fnIsPermutation(a) holds.
    static boolean
    fnIsPermutation(int[] a)
    Returns true if the array is a permutation of [0..a.length).
    static boolean
    fnIsTotal(int[] a)
    Returns true iff the array does not contain -1.
    static boolean
    hasDuplicates(boolean[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(byte[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(char[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(double[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(float[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(int[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(long[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    hasDuplicates(short[] a)
    Returns true iff a contains duplicate elements.
    static boolean
    Returns true iff a contains duplicate elements.
    static boolean
    Returns true iff a contains duplicate elements.
    static boolean
    hasNoDuplicates(boolean[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(byte[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(char[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(double[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(float[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(int[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(long[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    hasNoDuplicates(short[] a)
    Returns true iff a does not contain duplicate elements.
    static boolean
    Returns true iff a does not contain duplicate elements.
    static boolean
    Returns true iff a does not contain duplicate elements.
    static int
    indexOf(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int elt)
    Searches for the first occurrence of the given element in the array.
    static int
    indexOf(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int[] sub)
    Searches for the first subsequence of the array that matches the given array elementwise.
    static int
    indexOf(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the array, within the given boundaries.
    static int
    indexOf(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long elt)
    Searches for the first occurrence of the given element in the array.
    static int
    indexOf(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long[] sub)
    Searches for the first subsequence of the array that matches the given array elementwise.
    static int
    indexOf(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the array, within the given boundaries.
    static int
    indexOf(boolean[] a, boolean elt)
    Searches for the first occurrence of the given element in the array.
    static int
    indexOf(boolean[] a, boolean[] sub)
    Searches for the first subsequence of the array that matches the given array elementwise.
    static int
    indexOf(boolean[] a, boolean elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the array, within the given boundaries.
    static int
    indexOf(double[] a, double elt)
    Searches for the first occurrence of the given element in the array.
    static int
    indexOf(double[] a, double[] sub)
    Searches for the first subsequence of the array that matches the given array elementwise.
    static int
    indexOf(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub)
    Searches for the first subsequence of the array that matches the given array elementwise, testing for equality using the equals method.
    static int
    indexOf(@PolyNull @PolySigned Object[] a, List<? extends @PolyNull @PolySigned Object> sub)
    Searches for the first subsequence of the array that matches the given list elementwise, testing for equality using the equals method.
    static <T extends @Nullable Object>
    int
    indexOf(@PolySigned T[] a, @Nullable @PolySigned Object elt)
    Searches for the first occurrence of the given element in the array, testing for equality using the equals method.
    static <T extends @Nullable Object>
    int
    indexOf(@PolySigned T[] a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the array, within the given boundaries, testing for equality using the equals method.
    static int
    indexOf(List<? extends @PolyNull @PolySigned Object> a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}),@org.checkerframework.checker.index.qual.NonNegative int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the list, within the given boundaries, testing for equality using the equals method.
    static int
    indexOf(List<? extends @PolyNull @PolySigned Object> a, @PolyNull @PolySigned Object[] sub)
    Searches for the first subsequence of the list that matches the given array elementwise, testing for equality using the equals method.
    static int
    indexOf(List<? extends @PolyNull @PolySigned Object> a, @PolySigned Object elt)
    Searches for the first occurrence of the given element in the list, testing for equality using the equals method.
    static <T> int
    indexOf(List<T> a, List<T> sub)
    Searches for the first subsequence of the list that matches the given list elementwise, testing for equality using the equals method.
    static int
    indexOfEq(@PolyNull @PolySigned Object[] a, @Nullable @PolySigned Object elt)
    Searches for the first occurrence of the given element in the array, testing for equality using == (not the equals method).
    static int
    indexOfEq(@PolyNull @PolySigned Object[] a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the array, within the given boundaries, testing for equality using == (not the equals method).
    static int
    indexOfEq(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub)
    Searches for the first subsequence of the array that matches the given array elementwise, testing for equality using == (not the equals method).
    static <T> int
    indexOfEq(@PolyNull @PolySigned Object[] a, List<@PolySigned T> sub)
    Searches for the first subsequence of the array that matches the given list elementwise, testing for equality using == (not the equals method).
    static int
    indexOfEq(List<? extends @PolyNull @PolySigned Object> a, @Nullable @PolySigned Object elt)
    Searches for the first occurrence of the given element in the list, testing for equality using == (not the equals method).
    static int
    indexOfEq(List<? extends @PolyNull @PolySigned Object> a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}),@org.checkerframework.checker.index.qual.NonNegative int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
    Searches for the first occurrence of the given element in the list, within the given boundaries, testing for equality using == (not the equals method).
    static <T> int
    indexOfEq(List<@PolySigned T> a, @PolyNull @PolySigned Object[] sub)
    Searches for the first subsequence of the list that matches the given array elementwise, testing for equality using == (not the equals method).
    static <T> int
    indexOfEq(List<T> a, List<T> sub)
    Searches for the first subsequence of the list that matches the given list elementwise, testing for equality using == (not the equals method).
    static boolean
    Returns whether the array is sorted in descending order.
    static boolean
    Returns whether the array is sorted in descending order.
    static boolean
    isSubarray(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first.
    static boolean
    isSubarray(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first.
    static boolean
    isSubarray(boolean[] a, boolean[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first.
    static boolean
    isSubarray(double[] a, double[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first.
    static boolean
    isSubarray(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
    static boolean
    isSubarray(@PolyNull @PolySigned Object[] a, List<? extends @PolyNull @PolySigned Object> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
    static boolean
    isSubarray(List<? extends @PolyNull @PolySigned Object> a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
    static <T> boolean
    isSubarray(List<T> a, List<T> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
    static boolean
    isSubarrayEq(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
    static <T> boolean
    isSubarrayEq(@PolyNull @PolySigned Object[] a, List<@PolySigned T> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
    static <T> boolean
    isSubarrayEq(List<@PolySigned T> a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
    static <T> boolean
    isSubarrayEq(List<T> a, List<T> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
    Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
    static boolean
    isSubset(@org.checkerframework.checker.signedness.qual.PolySigned long[] smaller, @org.checkerframework.checker.signedness.qual.PolySigned long[] bigger)
    Returns whether smaller is a subset of bigger.
    static boolean
    isSubset(double[] smaller, double[] bigger)
    Returns whether smaller is a subset of bigger.
    static boolean
    isSubset(String[] smaller, String[] bigger)
    Returns whether smaller is a subset of bigger.
    static @org.checkerframework.checker.index.qual.NonNegative int
    length(@Nullable Object a)
    Returns the length of the argument array.
    static double
    max(double[] a)
    Returns the largest value in the array.
    static int
    max(int[] a)
    Returns the largest value in the array.
    static long
    max(long[] a)
    Returns the largest value in the array.
    static Double
    max(Double[] a)
    Returns the largest value in the array.
    static Integer
    max(Integer[] a)
    Returns the largest value in the array.
    static Long
    max(Long[] a)
    Returns the largest value in the array.
    static double
    min(double[] a)
    Returns the smallest value in the array.
    static int
    min(int[] a)
    Returns the smallest value in the array.
    static long
    min(long[] a)
    Returns the smallest value in the array.
    static Double
    min(Double[] a)
    Returns the smallest value in the array.
    static Integer
    min(Integer[] a)
    Returns the smallest value in the array.
    static Long
    min(Long[] a)
    Returns the smallest value in the array.
    static int @ArrayLen(2) []
    minAndMax(int[] a)
    Returns a two-element array containing the smallest and largest values in the array.
    static long @ArrayLen(2) []
    minAndMax(long[] a)
    Returns a two-element array containing the smallest and largest values in the array.
    static <T extends @Signed Object>
    T[]
    nCopies(@org.checkerframework.checker.index.qual.NonNegative int n, T o)
    Returns an array consisting of n copies of the specified object.
    static boolean
    noDuplicates(boolean[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(byte[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(char[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(double[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(float[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(int[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(long[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    noDuplicates(short[] a)
    Deprecated.
    use hasNoDuplicates
    static boolean
    Deprecated.
    use hasNoDuplicates
    static boolean
    Deprecated.
    use hasNoDuplicates
    static <T> boolean
    static int @SameLen("#1") []
    partialFnCompose(@org.checkerframework.checker.index.qual.IndexOrLow({"#2"}) int[] a, int[] b)
    Returns the composition of the given two (possibly partial) functions, all of which are represented as arrays.
    static <T extends @NonNull Object>
    List<org.plumelib.util.ArraysPlume.Partitioning<T>>
    partitionInto(Collection<T> elts, @org.checkerframework.checker.index.qual.NonNegative int k)
    Partition a set of non-null elements into exactly k subsets.
    static <T extends @NonNull Object>
    List<org.plumelib.util.ArraysPlume.Partitioning<T>>
    partitionInto(Queue<T> elts, @org.checkerframework.checker.index.qual.NonNegative int k)
    Partition a set of elements into exactly k subsets.
    static <T extends @NonNull Object>
    List<org.plumelib.util.ArraysPlume.Partitioning<T>>
    partitionIntoHelper(Queue<T> elts, List<org.plumelib.util.ArraysPlume.Partitioning<T>> resultSoFar, @org.checkerframework.checker.index.qual.NonNegative int numEmptyParts, @org.checkerframework.checker.index.qual.NonNegative int numNonemptyParts)
    Returns a set of partitionings, each of size numEmptyParts + numNonemptyParts.
    static <T> boolean
    sameContents(T[] arr1, T[] arr2)
    Returns true if the arrays contain the same contents, treated as a set (order and duplicates do not matter).
    static boolean
    sorted(int[] a)
    Returns whether the array is sorted.
    static boolean
    sorted(long[] a)
    Returns whether the array is sorted.
    static boolean[]
    subarray(boolean[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static byte[]
    subarray(byte[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static char[]
    subarray(char[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static double[]
    subarray(double[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static float[]
    subarray(float[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static int[]
    subarray(int[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static long[]
    subarray(long[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static short[]
    subarray(short[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static @PolyInterned @PolyNull Object[]
    subarray(@PolyInterned @PolyNull Object[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static @PolyInterned @PolyNull String[]
    subarray(@PolyInterned @PolyNull String[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
    Returns a subarray of the given array.
    static <T> List<T>
    subarray(List<T> a, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int startindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int length)
    Returns a sublist of the given list.
    static double
    sum(double[] a)
    Returns the sum of an array of doubles.
    static double
    sum(double[][] a)
    Returns the sum of all the elements of a 2d array of doubles.
    static int
    sum(int[] a)
    Returns the sum of an array of integers.
    static int
    sum(int[][] a)
    Returns the sum of all the elements of a 2d array of integers.
    static String
    toString(@Nullable Object a)
    Returns a string representation of the contents of the specified array.
    static String
    toString(@Nullable Collection<? extends @Signed @PolyNull Object> a, boolean quoted)
    Returns a string representation of the collection.
    static String
    toString(@Nullable Collection<? extends @PolyMustCall @Signed @PolyNull Object> a)
    Returns a string representation of the collection.
    static String
    toString(@PolyNull Object @Nullable [] a)
    Returns a string representation of the array.
    static String
    toString(@PolyNull Object @Nullable [] a, boolean quoted)
    Returns a string representation of the array.
    static String
    toStringQuoted(@Nullable Collection<? extends @PolyMustCall @Signed @Nullable Object> a)
    Returns a string representation of the collection.
    static String
    toStringQuoted(@PolyNull Object @Nullable [] a)
    Returns a string representation of the array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • nCopies

      public static <T extends @Signed Object> T[] nCopies(@org.checkerframework.checker.index.qual.NonNegative int n, T o)
      Returns an array consisting of n copies of the specified object.
      Type Parameters:
      T - the class of the object to copy. The returned array's element type is the run-time type of o.
      Parameters:
      n - the number of elements in the returned array
      o - the element to appear repeatedly in the returned array; must not be null
      Returns:
      an array consisting of n copies of the specified object
    • append

      public static <T> T[] append(T[] array, T lastElt)
      Concatenates an array and an element into a new array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array
      lastElt - the new last elemeent
      Returns:
      a new array containing the array elements and the last element, in that order
    • min

      @Pure public static int min(int[] a)
      Returns the smallest value in the array.
      Parameters:
      a - an array
      Returns:
      the smallest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • min

      @Pure public static long min(long[] a)
      Returns the smallest value in the array.
      Parameters:
      a - an array
      Returns:
      the smallest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • min

      @Pure public static double min(double[] a)
      Returns the smallest value in the array.
      Parameters:
      a - an array
      Returns:
      the smallest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • min

      @Pure public static Integer min(Integer[] a)
      Returns the smallest value in the array.
      Parameters:
      a - an array
      Returns:
      the smallest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • min

      @Pure public static Long min(Long[] a)
      Returns the smallest value in the array.
      Parameters:
      a - an array
      Returns:
      the smallest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • min

      @Pure public static Double min(Double[] a)
      Returns the smallest value in the array.
      Parameters:
      a - an array
      Returns:
      the smallest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • max

      @Pure public static int max(int[] a)
      Returns the largest value in the array.
      Parameters:
      a - an array
      Returns:
      the largest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • max

      @Pure public static long max(long[] a)
      Returns the largest value in the array.
      Parameters:
      a - an array
      Returns:
      the largest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • max

      @Pure public static double max(double[] a)
      Returns the largest value in the array.
      Parameters:
      a - an array
      Returns:
      the largest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • max

      @Pure public static Integer max(Integer[] a)
      Returns the largest value in the array.
      Parameters:
      a - an array
      Returns:
      the largest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • max

      @Pure public static Long max(Long[] a)
      Returns the largest value in the array.
      Parameters:
      a - an array
      Returns:
      the largest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • max

      @Pure public static Double max(Double[] a)
      Returns the largest value in the array.
      Parameters:
      a - an array
      Returns:
      the largest value in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • minAndMax

      @SideEffectFree public static int @ArrayLen(2) [] minAndMax(int[] a)
      Returns a two-element array containing the smallest and largest values in the array.
      Parameters:
      a - an array
      Returns:
      a two-element array containing the smallest and largest values in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • minAndMax

      @SideEffectFree public static long @ArrayLen(2) [] minAndMax(long[] a)
      Returns a two-element array containing the smallest and largest values in the array.
      Parameters:
      a - an array
      Returns:
      a two-element array containing the smallest and largest values in the array
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • elementRange

      @Pure @StaticallyExecutable public static int elementRange(int[] a)
      Returns the difference between the smallest and largest array elements.
      Parameters:
      a - an array
      Returns:
      the difference between the smallest and largest array elements
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • elementRange

      @Pure @StaticallyExecutable public static long elementRange(long[] a)
      Returns the difference between the smallest and largest array elements.
      Parameters:
      a - an array
      Returns:
      the difference between the smallest and largest array elements
      Throws:
      ArrayIndexOutOfBoundsException - if the array has length 0
    • sum

      @Pure @StaticallyExecutable public static int sum(int[] a)
      Returns the sum of an array of integers.
      Parameters:
      a - an array
      Returns:
      the sum of an array of integers
    • sum

      @Pure @StaticallyExecutable public static int sum(int[][] a)
      Returns the sum of all the elements of a 2d array of integers.
      Parameters:
      a - a 2d array
      Returns:
      the sum of all the elements of a 2d array of integers
    • sum

      @Pure @StaticallyExecutable public static double sum(double[] a)
      Returns the sum of an array of doubles.
      Parameters:
      a - an array
      Returns:
      the sum of an array of doubles
    • sum

      @Pure @StaticallyExecutable public static double sum(double[][] a)
      Returns the sum of all the elements of a 2d array of doubles.
      Parameters:
      a - a 2d array
      Returns:
      the sum of all the elements of a 2d array of doubles
    • indexOf

      @Pure public static <T extends @Nullable Object> int indexOf(@PolySigned T[] a, @Nullable @PolySigned Object elt)
      Searches for the first occurrence of the given element in the array, testing for equality using the equals method.
      Type Parameters:
      T - type of the elements of the array
      Parameters:
      a - an array
      elt - the element to search for
      Returns:
      the first index whose element is equal to the specified element, or -1 if no such element is found in the array
      See Also:
    • indexOf

      @Pure public static <T extends @Nullable Object> int indexOf(@PolySigned T[] a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the array, within the given boundaries, testing for equality using the equals method.
      Type Parameters:
      T - the type of the elements
      Parameters:
      a - an array
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <= i < indexlimit, or -1 if the element is not found in that section of the array
      See Also:
    • indexOf

      @Pure public static int indexOf(List<? extends @PolyNull @PolySigned Object> a, @PolySigned Object elt)
      Searches for the first occurrence of the given element in the list, testing for equality using the equals method. Identical to List.indexOf, but included for completeness.
      Parameters:
      a - a list
      elt - the element to search for
      Returns:
      the first index whose element is equal to the specified element, or -1 if no such element is found in the list
      See Also:
    • indexOf

      @Pure public static int indexOf(List<? extends @PolyNull @PolySigned Object> a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}),@org.checkerframework.checker.index.qual.NonNegative int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the list, within the given boundaries, testing for equality using the equals method.
      Parameters:
      a - a list
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <= i < indexlimit, or -1 if the element is not found in that section of the list
      See Also:
    • indexOfEq

      @Pure public static int indexOfEq(@PolyNull @PolySigned Object[] a, @Nullable @PolySigned Object elt)
      Searches for the first occurrence of the given element in the array, testing for equality using == (not the equals method).
      Parameters:
      a - an array
      elt - the element to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the array
      See Also:
    • indexOfEq

      @Pure public static int indexOfEq(@PolyNull @PolySigned Object[] a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the array, within the given boundaries, testing for equality using == (not the equals method).
      Parameters:
      a - an array
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <= i < indexlimit, or -1 if the element is not found in that section of the array
      See Also:
    • indexOfEq

      @Pure public static int indexOfEq(List<? extends @PolyNull @PolySigned Object> a, @Nullable @PolySigned Object elt)
      Searches for the first occurrence of the given element in the list, testing for equality using == (not the equals method).
      Parameters:
      a - a list
      elt - the element to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the list
      See Also:
    • indexOfEq

      @Pure public static int indexOfEq(List<? extends @PolyNull @PolySigned Object> a, @Nullable @PolySigned Object elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}),@org.checkerframework.checker.index.qual.NonNegative int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the list, within the given boundaries, testing for equality using == (not the equals method).
      Parameters:
      a - a list
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <= i < indexlimit, or -1 if the element is not found in that section of the list
      See Also:
    • indexOf

      @Pure public static int indexOf(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int elt)
      Searches for the first occurrence of the given element in the array.
      Parameters:
      a - an array
      elt - the element to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long elt)
      Searches for the first occurrence of the given element in the array.
      Parameters:
      a - an array
      elt - the element to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the array, within the given boundaries.
      Parameters:
      a - an array
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <=; i < indexlimit, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the array, within the given boundaries.
      Parameters:
      a - an array
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <=; i < indexlimit, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(boolean[] a, boolean elt)
      Searches for the first occurrence of the given element in the array.
      Parameters:
      a - an array
      elt - the element to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(double[] a, double elt)
      Searches for the first occurrence of the given element in the array.
      Parameters:
      a - an array
      elt - the element to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(boolean[] a, boolean elt, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int minindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int indexlimit)
      Searches for the first occurrence of the given element in the array, within the given boundaries.
      Parameters:
      a - an array
      elt - the element to search for
      minindex - first index at which to search
      indexlimit - first index at which not to search
      Returns:
      the first index i containing the specified element, such that minindex <=; i < indexlimit, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub)
      Searches for the first subsequence of the array that matches the given array elementwise, testing for equality using the equals method.
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first array, or -1 if no such element is found in the array
      See Also:
    • indexOfEq

      @Pure public static int indexOfEq(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub)
      Searches for the first subsequence of the array that matches the given array elementwise, testing for equality using == (not the equals method).
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first array, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(List<? extends @PolyNull @PolySigned Object> a, @PolyNull @PolySigned Object[] sub)
      Searches for the first subsequence of the list that matches the given array elementwise, testing for equality using the equals method.
      Parameters:
      a - a list
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first list, or -1 if no such element is found in the list
      See Also:
    • indexOfEq

      @Pure public static <T> int indexOfEq(List<@PolySigned T> a, @PolyNull @PolySigned Object[] sub)
      Searches for the first subsequence of the list that matches the given array elementwise, testing for equality using == (not the equals method).
      Type Parameters:
      T - the type of list/array elements
      Parameters:
      a - a list
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first list, or -1 if the element is not found in the list
      See Also:
    • indexOf

      @Pure public static int indexOf(@PolyNull @PolySigned Object[] a, List<? extends @PolyNull @PolySigned Object> sub)
      Searches for the first subsequence of the array that matches the given list elementwise, testing for equality using the equals method.
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second list starts in the first array, or -1 if no such element is found in the array
      See Also:
    • indexOfEq

      @Pure public static <T> int indexOfEq(@PolyNull @PolySigned Object[] a, List<@PolySigned T> sub)
      Searches for the first subsequence of the array that matches the given list elementwise, testing for equality using == (not the equals method).
      Type Parameters:
      T - the type of list/array elements
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second list starts in the first array, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static <T> int indexOf(List<T> a, List<T> sub)
      Searches for the first subsequence of the list that matches the given list elementwise, testing for equality using the equals method.
      Type Parameters:
      T - the type of list elements
      Parameters:
      a - a list
      sub - subsequence to search for
      Returns:
      the first index at which the second list starts in the first list, or -1 if no such element is found in the list
      See Also:
    • indexOfEq

      @Pure public static <T> int indexOfEq(List<T> a, List<T> sub)
      Searches for the first subsequence of the list that matches the given list elementwise, testing for equality using == (not the equals method).
      Type Parameters:
      T - the type of list elements
      Parameters:
      a - a list
      sub - subsequence to search for
      Returns:
      the first index at which the second list starts in the first list, or -1 if the element is not found in the list
      See Also:
    • indexOf

      @Pure public static int indexOf(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int[] sub)
      Searches for the first subsequence of the array that matches the given array elementwise.
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first array, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(double[] a, double[] sub)
      Searches for the first subsequence of the array that matches the given array elementwise.
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first array, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long[] sub)
      Searches for the first subsequence of the array that matches the given array elementwise.
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index at which the second array starts in the first array, or -1 if the element is not found in the array
      See Also:
    • indexOf

      @Pure public static int indexOf(boolean[] a, boolean[] sub)
      Searches for the first subsequence of the array that matches the given array elementwise.
      Parameters:
      a - an array
      sub - subsequence to search for
      Returns:
      the first index containing the specified element, or -1 if the element is not found in the array
      See Also:
    • subarray

      @SideEffectFree public static @PolyInterned @PolyNull Object[] subarray(@PolyInterned @PolyNull Object[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static <T> List<T> subarray(List<T> a, @org.checkerframework.checker.index.qual.IndexFor({"#1"}) int startindex, @org.checkerframework.checker.index.qual.IndexOrHigh({"#1"}) int length)
      Returns a sublist of the given list.
      Type Parameters:
      T - type of the elements
      Parameters:
      a - the original list
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a sublist of the given list
    • subarray

      @SideEffectFree public static @PolyInterned @PolyNull String[] subarray(@PolyInterned @PolyNull String[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static byte[] subarray(byte[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static boolean[] subarray(boolean[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static char[] subarray(char[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static double[] subarray(double[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static float[] subarray(float[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static int[] subarray(int[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static long[] subarray(long[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • subarray

      @SideEffectFree public static short[] subarray(short[] a, @org.checkerframework.checker.index.qual.NonNegative int startindex, @org.checkerframework.checker.index.qual.NonNegative,@org.checkerframework.checker.index.qual.LTLengthOf(value={"#1"}, offset={"#2 - 1"}) int length)
      Returns a subarray of the given array.
      Parameters:
      a - the original array
      startindex - the first index to be included
      length - the number of elements to include (not an end index, to avoid confusion over whether it would be the last included index or the first non-included index)
      Returns:
      a subarray of the given array
    • isSubarray

      @Pure public static boolean isSubarray(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarrayEq

      @Pure public static boolean isSubarrayEq(@PolyNull @PolySigned Object[] a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static boolean isSubarray(@PolyNull @PolySigned Object[] a, List<? extends @PolyNull @PolySigned Object> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarrayEq

      @Pure public static <T> boolean isSubarrayEq(@PolyNull @PolySigned Object[] a, List<@PolySigned T> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
      Type Parameters:
      T - the type of list/array elements
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static boolean isSubarray(List<? extends @PolyNull @PolySigned Object> a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
      Parameters:
      a - a list
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarrayEq

      @Pure public static <T> boolean isSubarrayEq(List<@PolySigned T> a, @PolyNull @PolySigned Object[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
      Type Parameters:
      T - the type of list/array elements
      Parameters:
      a - a list
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static <T> boolean isSubarray(List<T> a, List<T> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using the equals method.
      Type Parameters:
      T - the type of list elements
      Parameters:
      a - a list
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarrayEq

      @Pure public static <T> boolean isSubarrayEq(List<T> a, List<T> sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first, testing for equality using == (not the equals method).
      Type Parameters:
      T - the type of list elements
      Parameters:
      a - a list
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static boolean isSubarray(@org.checkerframework.checker.signedness.qual.PolySigned int[] a, @org.checkerframework.checker.signedness.qual.PolySigned int[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first.
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static boolean isSubarray(@org.checkerframework.checker.signedness.qual.PolySigned long[] a, @org.checkerframework.checker.signedness.qual.PolySigned long[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first.
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static boolean isSubarray(double[] a, double[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first.
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • isSubarray

      @Pure public static boolean isSubarray(boolean[] a, boolean[] sub, @org.checkerframework.checker.index.qual.NonNegative int aOffset)
      Determines whether the second array is a subarray of the first, starting at the specified index of the first.
      Parameters:
      a - an array
      sub - subsequence to search for
      aOffset - first index in a at which to search. Must be non-negative. The routine returns false if aOffset is too large to be a valid index for a.
      Returns:
      true iff sub is a contiguous subarray of a
    • concatenate

      public static <T> T[] concatenate(T[] array1, T... array2)
      Concatenates two arrays. Can be invoked varargs-style.

      This differs from concat in that it always returns a new array, never an existing array.

      Type Parameters:
      T - the type of the array elements
      Parameters:
      array1 - the first array
      array2 - the second array
      Returns:
      a new array containing the contents of the given arrays, in order
    • concat

      public static <T extends @Nullable Object> T[] concat(T @Nullable [] a, T @Nullable [] b)
      Returns an array that contains all the elements of both arguments, in order. Returns an existing array if possible (when one argument is null or empty).
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      public static <T extends @Nullable Object> T[] concat(T @Nullable [] a, @Nullable List<T> b)
      Returns an array that contains all the elements of both arguments, in order. Returns the array argument if the list argument is null or empty.
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      public static <T extends @Nullable Object> T[] concat(@Nullable List<T> a, T @Nullable [] b)
      Returns an array that contains all the elements of both arguments, in order. Returns the array argument if the list argument is null or empty.
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      public static <T extends @Nullable Object> T[] concat(@Nullable List<T> a, @Nullable List<T> b)
      Returns an array that contains all the elements of both arguments, in order.
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      public static @PolyInterned @PolyNull String[] concat(@PolyInterned @PolyNull String @Nullable [] a, @PolyInterned @PolyNull String @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null or empty, in which case it returns the other array.
      Parameters:
      a - the first array to concatenate
      b - the second array to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static byte[] concat(byte @Nullable [] a, byte @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static boolean[] concat(boolean @Nullable [] a, boolean @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static char[] concat(char @Nullable [] a, char @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static double[] concat(double @Nullable [] a, double @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static float[] concat(float @Nullable [] a, float @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static int[] concat(int @Nullable [] a, int @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static long[] concat(long @Nullable [] a, long @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • concat

      @SideEffectFree public static short[] concat(short @Nullable [] a, short @Nullable [] b)
      Returns an array that contains all the elements of both argument arrays, in order. Returns a new array unless one argument is null, in which case it returns the other array.
      Parameters:
      a - the first sequence to concatenate
      b - the second sequence to concatenate
      Returns:
      an array that concatenates the arguments
    • length

      @Pure public static @org.checkerframework.checker.index.qual.NonNegative int length(@Nullable Object a) throws IllegalArgumentException
      Returns the length of the argument array.
      Parameters:
      a - an array
      Returns:
      the length of the array
      Throws:
      IllegalArgumentException - if obj is null or is not an array
    • toString

      @SideEffectFree public static String toString(@Nullable Object a)
      Returns a string representation of the contents of the specified array. The argument must be an array or null. This just dispatches one of the 9 overloaded versions of java.util.Arrays.toString().
      Parameters:
      a - an array
      Returns:
      a string representation of the array
      Throws:
      IllegalArgumentException - if a is not an array
    • toString

      @SideEffectFree public static String toString(@PolyNull Object @Nullable [] a)
      Returns a string representation of the array. The representation is patterned after that of java.util.ArrayList.
      Parameters:
      a - an array
      Returns:
      a string representation of the array
      See Also:
    • toString

      @SideEffectFree public static String toString(@PolyNull Object @Nullable [] a, boolean quoted)
      Returns a string representation of the array. The representation is patterned after that of java.util.ArrayList. Furthermore, if quoted is true, then each element is quoted like a Java String.
      Parameters:
      a - an array
      quoted - whether to quote the array elements
      Returns:
      a string representation of the array
      See Also:
    • toString

      @SideEffectFree public static String toString(@Nullable Collection<? extends @PolyMustCall @Signed @PolyNull Object> a)
      Returns a string representation of the collection. The representation is patterned after that of java.util.ArrayList.
      Parameters:
      a - a collection
      Returns:
      a string representation of the collection
      See Also:
    • toString

      @SideEffectFree public static String toString(@Nullable Collection<? extends @Signed @PolyNull Object> a, boolean quoted)
      Returns a string representation of the collection. The representation is patterned after that of java.util.ArrayList. The representation permits quoting (or not) of strings.
      Parameters:
      a - a collection
      quoted - whether to quote the collection elements that are Java strings
      Returns:
      a string representation of the list
      See Also:
    • toStringQuoted

      @SideEffectFree public static String toStringQuoted(@PolyNull Object @Nullable [] a)
      Returns a string representation of the array. The representation is patterned after that of java.util.ArrayList. Furthermore, each element is quoted like a Java String.
      Parameters:
      a - an array
      Returns:
      a string representation of the array, with the elements quoted
      See Also:
    • toStringQuoted

      @SideEffectFree public static String toStringQuoted(@Nullable Collection<? extends @PolyMustCall @Signed @Nullable Object> a)
      Returns a string representation of the collection. The representation is patterned after that of java.util.ArrayList.
      Parameters:
      a - a collection
      Returns:
      a string representation of the collection, with the elements quoted
      See Also:
    • sorted

      @Pure public static boolean sorted(int[] a)
      Returns whether the array is sorted.
      Parameters:
      a - an array
      Returns:
      true iff the array is sorted
    • sorted

      @Pure public static boolean sorted(long[] a)
      Returns whether the array is sorted.
      Parameters:
      a - an array
      Returns:
      true iff the array is sorted
    • isSortedDescending

      @Pure public static boolean isSortedDescending(int[] a)
      Returns whether the array is sorted in descending order.
      Parameters:
      a - an array
      Returns:
      true iff the array is sorted in descending order
    • isSortedDescending

      @Pure public static boolean isSortedDescending(long[] a)
      Returns whether the array is sorted in descending order.
      Parameters:
      a - an array
      Returns:
      true iff the array is sorted in descending order
    • hasDuplicates

      @Pure public static boolean hasDuplicates(boolean[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(boolean[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(boolean[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(byte[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(byte[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(byte[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(char[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(char[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(char[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(float[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(float[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(float[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(short[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(short[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(short[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(int[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(int[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(int[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(double[] a)
      Returns true iff a contains duplicate elements. Equality checking uses Double.equals(java.lang.Object).

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(double[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements. Equality checking uses Double.equals(java.lang.Object).

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(double[] a)
      Returns true iff a does not contain duplicate elements. Equality checking uses Double.equals(java.lang.Object).

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(long[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(long[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(long[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(String[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(String[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(String[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasDuplicates

      @Pure public static boolean hasDuplicates(Object[] a)
      Returns true iff a contains duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a contains duplicate elements
    • noDuplicates

      @Deprecated @Pure public static boolean noDuplicates(Object[] a)
      Deprecated.
      use hasNoDuplicates
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • hasNoDuplicates

      @Pure public static boolean hasNoDuplicates(Object[] a)
      Returns true iff a does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Parameters:
      a - an array
      Returns:
      true iff a does not contain duplicate elements
    • noDuplicates

      @Deprecated @Pure public static <T> boolean noDuplicates(List<T> a)
      Returns true iff the list does not contain duplicate elements.

      The implementation uses O(n) time and O(n) space.

      Type Parameters:
      T - the type of the elements
      Parameters:
      a - a list
      Returns:
      true iff a does not contain duplicate elements
    • fnIsPermutation

      @Pure public static boolean fnIsPermutation(int[] a)
      Returns true if the array is a permutation of [0..a.length).
      Parameters:
      a - an array, representing a function
      Returns:
      true iff all elements of a are in [0..a.length) and a contains no duplicates.
    • fnIsTotal

      @Pure public static boolean fnIsTotal(int[] a)
      Returns true iff the array does not contain -1.
      Parameters:
      a - an array, representing a function
      Returns:
      true iff no element of a maps to -1
    • fnIdentity

      public static int[] fnIdentity(@org.checkerframework.checker.index.qual.NonNegative int length)
      Returns an array [0..length).
      Parameters:
      length - the length of the result
      Returns:
      fresh array that is the identity function of the given length
    • fnInversePermutation

      @SideEffectFree public static int[] fnInversePermutation(int[] a)
      Requires that fnIsPermutation(a) holds.
      Parameters:
      a - the input permutation
      Returns:
      fresh array which is the inverse of the given permutation
      See Also:
    • fnInverse

      @SideEffectFree public static int[] fnInverse(int[] a, @org.checkerframework.checker.index.qual.NonNegative int arange)
      Returns the inverse of the given function, which is represented as an array.
      Parameters:
      a - an array representing a function from [0..a.length) to [0..arange); each element of a is between 0 (inclusive) and arange (exclusive)
      arange - length of the argument's range and the result's domain
      Returns:
      function from [0..arange) to [0..a.length) that is the inverse of a
      Throws:
      IllegalArgumentException - if a value of a is outside of arange
      UnsupportedOperationException - when the function is not invertible
    • fnCompose

      @SideEffectFree public static int @SameLen("#1") [] fnCompose(@org.checkerframework.checker.index.qual.IndexFor({"#2"}) int[] a, int[] b)
      Returns the composition of the given two functions, all of which are represented as arrays.
      Parameters:
      a - function from [0..a.length) to [0..b.length)
      b - function from [0..b.length) to range R
      Returns:
      function from [0..a.length) to range R that is the composition of a and b
    • partialFnCompose

      @SideEffectFree public static int @SameLen("#1") [] partialFnCompose(@org.checkerframework.checker.index.qual.IndexOrLow({"#2"}) int[] a, int[] b)
      Returns the composition of the given two (possibly partial) functions, all of which are represented as arrays.
      Parameters:
      a - function from [0..a.length) to [-1..b.length)
      b - function from [0..b.length) to range R
      Returns:
      function from [0..a.length) to {range R} union {-1}, that is the composition of a and b.
    • isSubset

      @Pure public static boolean isSubset(@org.checkerframework.checker.signedness.qual.PolySigned long[] smaller, @org.checkerframework.checker.signedness.qual.PolySigned long[] bigger)
      Returns whether smaller is a subset of bigger.

      The implementation is to use collections because we want to take advantage of HashSet's constant time membership tests.

      Parameters:
      smaller - first set to test
      bigger - second set to test
      Returns:
      true iff smaller is a subset of bigger
    • isSubset

      @Pure public static boolean isSubset(double[] smaller, double[] bigger)
      Returns whether smaller is a subset of bigger.

      The implementation is to use collections because we want to take advantage of HashSet's constant time membership tests.

      Parameters:
      smaller - first set to test
      bigger - second set to test
      Returns:
      true iff smaller is a subset of bigger
    • isSubset

      @Pure public static boolean isSubset(String[] smaller, String[] bigger)
      Returns whether smaller is a subset of bigger.

      The implementation is to use collections because we want to take advantage of HashSet's constant time membership tests.

      Parameters:
      smaller - first set to test
      bigger - second set to test
      Returns:
      true iff smaller is a subset of bigger
    • sameContents

      public static <T> boolean sameContents(T[] arr1, T[] arr2)
      Returns true if the arrays contain the same contents, treated as a set (order and duplicates do not matter).
      Type Parameters:
      T - the type of the array contents
      Parameters:
      arr1 - an array
      arr2 - an array
      Returns:
      true if the arrays contain the same contents
    • anyNull

      @Pure public static boolean anyNull(@PolyNull @PolySigned Object[] a)
      Returns true if a contains null.
      Parameters:
      a - an array
      Returns:
      true iff some element of a is null (false if a is zero-sized)
    • allNull

      @Pure public static boolean allNull(@PolyNull Object[] a)
      Returns true if all elements of a are null.
      Parameters:
      a - an array
      Returns:
      true iff all elements of a are null (unspecified result if a is zero-sized)
    • anyNull

      @Pure public static boolean anyNull(List<? extends @Nullable Object> a)
      Returns true if a contains null.
      Parameters:
      a - an array
      Returns:
      true iff some element of a is null (false if a is zero-sized)
    • allNull

      @Pure public static boolean allNull(List<?> a)
      Returns true if all elements of a are null.
      Parameters:
      a - an array
      Returns:
      true iff all elements of a are null (unspecified result if a is zero-sized)
    • partitionInto

      public static <T extends @NonNull Object> List<org.plumelib.util.ArraysPlume.Partitioning<T>> partitionInto(Collection<T> elts, @org.checkerframework.checker.index.qual.NonNegative int k)
      Partition a set of non-null elements into exactly k subsets. A partitioning is of type List<List<T>>, where the union of the inner lists is elts. This method returns a list of such partitionings.
      Type Parameters:
      T - type of items to be partitioned
      Parameters:
      elts - items to be partitioned
      k - number of subsets into which to partition elts
      Returns:
      a list of partitionings, where each contains exactly k subsets
    • partitionInto

      public static <T extends @NonNull Object> List<org.plumelib.util.ArraysPlume.Partitioning<T>> partitionInto(Queue<T> elts, @org.checkerframework.checker.index.qual.NonNegative int k)
      Partition a set of elements into exactly k subsets. A partitioning is of type List<List<T>>, where the union of the inner lists is elts. This method returns a list of such partitionings.
      Type Parameters:
      T - type of items to be partitioned
      Parameters:
      elts - items to be partitioned
      k - number of subsets into which to partition elts
      Returns:
      a list of partitionings, where each contains exactly k subsets
    • partitionIntoHelper

      public static <T extends @NonNull Object> List<org.plumelib.util.ArraysPlume.Partitioning<T>> partitionIntoHelper(Queue<T> elts, List<org.plumelib.util.ArraysPlume.Partitioning<T>> resultSoFar, @org.checkerframework.checker.index.qual.NonNegative int numEmptyParts, @org.checkerframework.checker.index.qual.NonNegative int numNonemptyParts)
      Returns a set of partitionings, each of size numEmptyParts + numNonemptyParts. A helper method for partitionInto(java.util.Collection<T>, int).
      Type Parameters:
      T - type of items to be partitioned
      Parameters:
      elts - the elements that remain to be added to the partitionings
      resultSoFar - a list of partitionings, each of which has numNonemptyParts parts
      numEmptyParts - the number of partitions in the partitioning that are empty so far
      numNonemptyParts - the number of partitions in the partitioning that have at least one member so far
      Returns:
      a list of partitionings, where each contains exactly k subsets