public final class ArraysPlume
extends java.lang.Object
Arrays and
Collections.| Modifier and Type | Class and Description |
|---|---|
static class |
ArraysPlume.ComparableArrayComparatorLengthFirst<T extends java.lang.Comparable<T>>
Compare two arrays first by length (a shorter array is considered less), and if of equal length
compare lexically (element-by-element).
|
static class |
ArraysPlume.ComparableArrayComparatorLexical<T extends java.lang.Comparable<T>>
Compare two arrays lexically (element-by-element).
|
static class |
ArraysPlume.DoubleArrayComparatorLexical
Compare two arrays lexically (element-by-element).
|
static class |
ArraysPlume.IntArrayComparatorLengthFirst
Compare two arrays first by length (a shorter array is considered less), and if of equal length
compare lexically (element-by-element).
|
static class |
ArraysPlume.IntArrayComparatorLexical
Compare two arrays lexically (element-by-element).
|
static class |
ArraysPlume.LongArrayComparatorLengthFirst
Compare two arrays first by length (a shorter array is considered less), and if of equal length
compare lexically (element-by-element).
|
static class |
ArraysPlume.LongArrayComparatorLexical
Compare two arrays lexically (element-by-element).
|
static class |
ArraysPlume.ObjectArrayComparatorLengthFirst
Compare two arrays first by length (a shorter array is considered less), and if of equal length
compare lexically (element-by-element).
|
static class |
ArraysPlume.ObjectArrayComparatorLexical
Compare two arrays lexically (element-by-element).
|
static class |
ArraysPlume.StringArrayComparatorLexical
Compare two arrays lexically (element-by-element).
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
allNull(java.util.List<?> a)
Return true if all elements of a are null.
|
static boolean |
allNull(@PolyAll java.lang.Object[] a)
Return true if all elements of a are null.
|
static boolean |
anyNull(java.util.List<?> a)
Return true if a contains null.
|
static boolean |
anyNull(@PolyAll java.lang.Object[] a)
Return true if a contains null.
|
static boolean[] |
concat(boolean[] a,
boolean[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static byte[] |
concat(byte[] a,
byte[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static char[] |
concat(char[] a,
char[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static double[] |
concat(double[] a,
double[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static float[] |
concat(float[] a,
float[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static int[] |
concat(int[] a,
int[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static <T> T[] |
concat(@Nullable java.util.List<T> a,
@Nullable java.util.List<T> b)
Return an array that contains all the elements of both arguments, in order.
|
static <T> T[] |
concat(@Nullable java.util.List<T> a,
T[] b)
Return an array that contains all the elements of both arguments, in order.
|
static long[] |
concat(long[] a,
long[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static short[] |
concat(short[] a,
short[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static @PolyAll java.lang.String[] |
concat(@PolyAll java.lang.String[] a,
@PolyAll java.lang.String[] b)
Return an array that contains all the elements of both argument arrays, in order.
|
static <T> T[] |
concat(T[] a,
@Nullable java.util.List<T> b)
Return an array that contains all the elements of both arguments, in order.
|
static <T> T[] |
concat(T[] a,
T[] b)
Return an array that contains all the elements of both arguments, in order.
|
static int |
elementRange(int[] a)
Return the difference between the smallest and largest array elements.
|
static long |
elementRange(long[] a)
Return the difference between the smallest and largest array elements.
|
static @PolyAll int[] |
fnCompose(int[] a,
@PolyAll int[] b)
Return the composition of the given two functions, all of which are represented as arrays.
|
static int[] |
fnIdentity(int length)
Return an array [0..length).
|
static int[] |
fnInverse(int[] a,
int arange)
Return the inverse of the given function, which is represented as an array.
|
static int[] |
fnInversePermutation(int[] a)
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)
Return true iff the array does not contain -1.
|
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,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the array.
|
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(int[] a,
int elt)
Searches for the first occurrence of the given element in the array.
|
static int |
indexOf(int[] a,
int[] sub)
Searches for the first subsequence of the array that matches the given array elementwise.
|
static int |
indexOf(int[] a,
int elt,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the array.
|
static int |
indexOf(java.util.List<?> a,
java.util.List<?> sub)
Searches for the first subsequence of the list that matches the given list elementwise, testing
for equality using the equals method.
|
static int |
indexOf(java.util.List<?> a,
@PolyAll java.lang.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(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt)
Searches for the first occurrence of the given element in the list, testing for equality using
the equals method.
|
static int |
indexOf(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the list, testing for equality using
the equals method.
|
static int |
indexOf(long[] a,
long elt)
Searches for the first occurrence of the given element in the array.
|
static int |
indexOf(long[] a,
long[] sub)
Searches for the first subsequence of the array that matches the given array elementwise.
|
static int |
indexOf(long[] a,
long elt,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the array.
|
static int |
indexOf(@PolyAll java.lang.Object[] a,
java.util.List<?> sub)
Searches for the first subsequence of the array that matches the given list elementwise,
testing for equality using the equals method.
|
static int |
indexOf(@PolyAll java.lang.Object[] a,
java.lang.Object[] sub)
Searches for the first subsequence of the array that matches the given array elementwise,
testing for equality using the equals method.
|
static <T> int |
indexOf(T[] a,
@Nullable java.lang.Object elt)
Searches for the first occurrence of the given element in the array, testing for equality using
the equals method.
|
static <T> int |
indexOf(T[] a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the array, testing for equality using
the equals method.
|
static int |
indexOfEq(java.util.List<?> a,
java.util.List<?> sub)
Searches for the first subsequence of the list that matches the given list elementwise, testing
for equality using == (not the equals method).
|
static int |
indexOfEq(java.util.List<?> a,
@PolyAll java.lang.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 int |
indexOfEq(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.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(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the list, testing for equality using
== (not the equals method).
|
static int |
indexOfEq(@PolyAll java.lang.Object[] a,
java.util.List<?> 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(@PolyAll java.lang.Object[] a,
@Nullable java.lang.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(@PolyAll java.lang.Object[] a,
@PolyAll java.lang.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 int |
indexOfEq(@PolyNull java.lang.Object[] a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
Searches for the first occurrence of the given element in the array, testing for equality using
== (not the equals method).
|
static boolean |
isSortedDescending(int[] a)
Returns whether the array is sorted in descending order.
|
static boolean |
isSortedDescending(long[] a)
Returns whether the array is sorted in descending order.
|
static boolean |
isSubarray(boolean[] a,
boolean[] sub,
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,
int aOffset)
Determines whether the second array is a subarray of the first, starting at the specified index
of the first.
|
static boolean |
isSubarray(int[] a,
int[] sub,
int aOffset)
Determines whether the second array is a subarray of the first, starting at the specified index
of the first.
|
static boolean |
isSubarray(java.util.List<?> a,
java.util.List<?> sub,
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(java.util.List<?> a,
@PolyAll java.lang.Object[] sub,
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(long[] a,
long[] sub,
int aOffset)
Determines whether the second array is a subarray of the first, starting at the specified index
of the first.
|
static boolean |
isSubarray(@PolyAll java.lang.Object[] a,
java.util.List<?> sub,
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(@PolyAll java.lang.Object[] a,
@PolyNull java.lang.Object[] sub,
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(java.util.List<?> a,
java.util.List<?> sub,
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 |
isSubarrayEq(java.util.List<?> a,
@PolyAll java.lang.Object[] sub,
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 |
isSubarrayEq(@PolyAll java.lang.Object[] a,
java.util.List<?> sub,
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 |
isSubarrayEq(@PolyAll java.lang.Object[] a,
@PolyAll java.lang.Object[] sub,
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(double[] smaller,
double[] bigger)
Return whether smaller is a subset of bigger.
|
static boolean |
isSubset(long[] smaller,
long[] bigger)
Return whether smaller is a subset of bigger.
|
static boolean |
isSubset(java.lang.String[] smaller,
java.lang.String[] bigger)
Return whether smaller is a subset of bigger.
|
static int |
length(java.lang.Object a)
Returns the length of the argument array.
|
static double |
max(double[] a)
Return the largest value in the array.
|
static java.lang.Double |
max(java.lang.Double[] a)
Return the largest value in the array.
|
static int |
max(int[] a)
Return the largest value in the array.
|
static java.lang.Integer |
max(java.lang.Integer[] a)
Return the largest value in the array.
|
static long |
max(long[] a)
Return the largest value in the array.
|
static java.lang.Long |
max(java.lang.Long[] a)
Return the largest value in the array.
|
static double |
min(double[] a)
Return the smallest value in the array.
|
static java.lang.Double |
min(java.lang.Double[] a)
Return the smallest value in the array.
|
static int |
min(int[] a)
Return the smallest value in the array.
|
static java.lang.Integer |
min(java.lang.Integer[] a)
Return the smallest value in the array.
|
static long |
min(long[] a)
Return the smallest value in the array.
|
static java.lang.Long |
min(java.lang.Long[] a)
Return the smallest value in the array.
|
static int[] |
minAndMax(int[] a)
Return a two-element array containing the smallest and largest values in the array.
|
static long[] |
minAndMax(long[] a)
Return a two-element array containing the smallest and largest values in the array.
|
static boolean |
noDuplicates(boolean[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(byte[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(char[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(double[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(float[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(int[] a)
Return true iff a does not contain duplicate elements.
|
static <T> boolean |
noDuplicates(java.util.List<T> a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(long[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(java.lang.Object[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(short[] a)
Return true iff a does not contain duplicate elements.
|
static boolean |
noDuplicates(java.lang.String[] a)
Return true iff a does not contain duplicate elements.
|
static int[] |
partialFnCompose(int[] a,
int[] b)
Return the composition of the given two (possibly partial) functions, all of which are
represented as arrays.
|
static <T> java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> |
partitionInto(java.util.Collection<T> elts,
int k)
Partition a set of non-null elements into exactly k subsets.
|
static <T> java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> |
partitionInto(java.util.Queue<T> elts,
int k)
Partition a set of elements into exactly k subsets.
|
static <T> java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> |
partitionIntoHelper(java.util.Queue<T> elts,
java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> resultSoFar,
int numEmptyParts,
int numNonemptyParts)
Returns a set of partitionings, each of size numEmptyParts + numNonemptyParts.
|
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,
int startindex,
int length)
Return a subarray of the given array.
|
static byte[] |
subarray(byte[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static char[] |
subarray(char[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static double[] |
subarray(double[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static float[] |
subarray(float[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static int[] |
subarray(int[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static <T> java.util.List<T> |
subarray(java.util.List<T> a,
int startindex,
int length)
Return a sublist of the given list.
|
static long[] |
subarray(long[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static @PolyAll java.lang.Object[] |
subarray(@PolyAll java.lang.Object[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static short[] |
subarray(short[] a,
int startindex,
int length)
Return a subarray of the given array.
|
static @PolyAll java.lang.String[] |
subarray(@PolyAll java.lang.String[] a,
int startindex,
int length)
Return a subarray of the given array.
|
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 java.lang.String |
toString(@Nullable java.util.Collection<?> a)
Return a string representation of the collection.
|
static java.lang.String |
toString(@Nullable java.util.Collection<?> a,
boolean quoted)
Return a string representation of the collection.
|
static java.lang.String |
toString(java.lang.Object a)
Returns a string representation of the contents of the specified array.
|
static java.lang.String |
toString(@PolyAll java.lang.Object[] a)
Return a string representation of the array.
|
static java.lang.String |
toString(@PolyAll java.lang.Object[] a,
boolean quoted)
Return a string representation of the array.
|
static java.lang.String |
toStringQuoted(@Nullable java.util.Collection<?> a)
Return a string representation of the collection.
|
static java.lang.String |
toStringQuoted(@PolyAll java.lang.Object[] a)
Return a string representation of the array.
|
@Pure public static int min(int[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static long min(long[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static double min(double[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static java.lang.Integer min(java.lang.Integer[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static java.lang.Long min(java.lang.Long[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static java.lang.Double min(java.lang.Double[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static int max(int[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static long max(long[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static double max(double[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static java.lang.Integer max(java.lang.Integer[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static java.lang.Long max(java.lang.Long[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static java.lang.Double max(java.lang.Double[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static int[] minAndMax(int[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static long[] minAndMax(long[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static int elementRange(int[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static long elementRange(long[] a)
a - an arrayjava.lang.ArrayIndexOutOfBoundsException - if the array has length 0@Pure public static int sum(int[] a)
a - an array@Pure public static int sum(int[][] a)
a - a 2d array@Pure public static double sum(double[] a)
a - an array@Pure public static double sum(double[][] a)
a - a 2d array@Pure
public static <T> int indexOf(T[] a,
@Nullable java.lang.Object elt)
T - type of the elements of the arraya - an arrayelt - the element to search forList.indexOf(java.lang.Object)@Pure
public static <T> int indexOf(T[] a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
T - the type of the elementsa - an arrayelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in that section of the arrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt)
a - a listelt - the element to search forList.indexOf(java.lang.Object)@Pure
public static int indexOf(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
a - a listelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in that section of the listList.indexOf(java.lang.Object)@Pure
public static int indexOfEq(@PolyAll java.lang.Object[] a,
@Nullable java.lang.Object elt)
a - an arrayelt - the element to search forArrayList.indexOf(java.lang.Object)@Pure
public static int indexOfEq(@PolyNull java.lang.Object[] a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
a - an arrayelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in that section of the arrayArrayList.indexOf(java.lang.Object)@Pure
public static int indexOfEq(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt)
a - a listelt - the element to search forArrayList.indexOf(java.lang.Object)@Pure
public static int indexOfEq(java.util.List<? extends java.lang.Object> a,
@Nullable java.lang.Object elt,
int minindex,
int indexlimit)
a - a listelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in that section of the listArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(int[] a,
int elt)
a - an arrayelt - the element to search forArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(long[] a,
long elt)
a - an arrayelt - the element to search forArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(int[] a,
int elt,
int minindex,
int indexlimit)
a - an arrayelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in the arrayArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(long[] a,
long elt,
int minindex,
int indexlimit)
a - an arrayelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in the arrayArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(boolean[] a,
boolean elt)
a - an arrayelt - the element to search forArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(double[] a,
double elt)
a - an arrayelt - the element to search forArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(boolean[] a,
boolean elt,
int minindex,
int indexlimit)
a - an arrayelt - the element to search forminindex - first index at which to searchindexlimit - first index at which not to searchminindex ≤ i <
indexlimit, or -1 if the element is not found in the arrayArrayList.indexOf(java.lang.Object)@Pure
public static int indexOf(@PolyAll java.lang.Object[] a,
java.lang.Object[] sub)
a - an arraysub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOfEq(@PolyAll java.lang.Object[] a,
@PolyAll java.lang.Object[] sub)
a - an arraysub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(java.util.List<?> a,
@PolyAll java.lang.Object[] sub)
a - a listsub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOfEq(java.util.List<?> a,
@PolyAll java.lang.Object[] sub)
a - a listsub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(@PolyAll java.lang.Object[] a,
java.util.List<?> sub)
a - a listsub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOfEq(@PolyAll java.lang.Object[] a,
java.util.List<?> sub)
a - a listsub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(java.util.List<?> a,
java.util.List<?> sub)
a - a listsub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOfEq(java.util.List<?> a,
java.util.List<?> sub)
a - a listsub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(int[] a,
int[] sub)
a - an arraysub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(double[] a,
double[] sub)
a - an arraysub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(long[] a,
long[] sub)
a - an arraysub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@Pure
public static int indexOf(boolean[] a,
boolean[] sub)
a - an arraysub - subsequence to search forArrayList.indexOf(java.lang.Object),
String.indexOf(java.lang.String)@SideEffectFree
public static @PolyAll java.lang.Object[] subarray(@PolyAll java.lang.Object[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static <T> java.util.List<T> subarray(java.util.List<T> a,
int startindex,
int length)
T - type of the elementsa - the original liststartindex - the first index to be includedlength - 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)@SideEffectFree
public static @PolyAll java.lang.String[] subarray(@PolyAll java.lang.String[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static byte[] subarray(byte[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static boolean[] subarray(boolean[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static char[] subarray(char[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static double[] subarray(double[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static float[] subarray(float[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static int[] subarray(int[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static long[] subarray(long[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@SideEffectFree
public static short[] subarray(short[] a,
int startindex,
int length)
a - the original arraystartindex - the first index to be includedlength - 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)@Pure
public static boolean isSubarray(@PolyAll java.lang.Object[] a,
@PolyNull java.lang.Object[] sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarrayEq(@PolyAll java.lang.Object[] a,
@PolyAll java.lang.Object[] sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(@PolyAll java.lang.Object[] a,
java.util.List<?> sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarrayEq(@PolyAll java.lang.Object[] a,
java.util.List<?> sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(java.util.List<?> a,
@PolyAll java.lang.Object[] sub,
int aOffset)
a - a listsub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarrayEq(java.util.List<?> a,
@PolyAll java.lang.Object[] sub,
int aOffset)
a - a listsub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(java.util.List<?> a,
java.util.List<?> sub,
int aOffset)
a - a listsub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarrayEq(java.util.List<?> a,
java.util.List<?> sub,
int aOffset)
a - a listsub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(int[] a,
int[] sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(long[] a,
long[] sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(double[] a,
double[] sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.@Pure
public static boolean isSubarray(boolean[] a,
boolean[] sub,
int aOffset)
a - an arraysub - subsequence to search foraOffset - first index in a at which to search. Must be non-negative. The routine
returns false if aAffset is too large to be a valid index for a.public static <T> T[] concat(T[] a,
T[] b)
T - the type of the sequence elementsa - the first sequence to concatenateb - the second sequence to concatenatepublic static <T> T[] concat(T[] a,
@Nullable java.util.List<T> b)
T - the type of the sequence elementsa - the first sequence to concatenateb - the second sequence to concatenatepublic static <T> T[] concat(@Nullable java.util.List<T> a,
T[] b)
T - the type of the sequence elementsa - the first sequence to concatenateb - the second sequence to concatenatepublic static <T> T[] concat(@Nullable java.util.List<T> a,
@Nullable java.util.List<T> b)
T - the type of the sequence elementsa - the first sequence to concatenateb - the second sequence to concatenatepublic static @PolyAll java.lang.String[] concat(@PolyAll java.lang.String[] a,
@PolyAll java.lang.String[] b)
a - the first array to concatenateb - the second array to concatenatepublic static byte[] concat(byte[] a,
byte[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static boolean[] concat(boolean[] a,
boolean[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static char[] concat(char[] a,
char[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static double[] concat(double[] a,
double[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static float[] concat(float[] a,
float[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static int[] concat(int[] a,
int[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static long[] concat(long[] a,
long[] b)
a - the first sequence to concatenateb - the second sequence to concatenatepublic static short[] concat(short[] a,
short[] b)
a - the first sequence to concatenateb - the second sequence to concatenate@SideEffectFree public static java.lang.String toString(java.lang.Object a)
java.util.Arrays.toString().a - an arrayjava.lang.IllegalArgumentException - if a is not an array@Pure
public static int length(java.lang.Object a)
throws java.lang.IllegalArgumentException
a - an arrayjava.lang.IllegalArgumentException - if obj is null or is not an array@SideEffectFree public static java.lang.String toString(@PolyAll java.lang.Object[] a)
a - an arrayAbstractCollection.toString()@SideEffectFree public static java.lang.String toStringQuoted(@PolyAll java.lang.Object[] a)
a - an arrayAbstractCollection.toString()@SideEffectFree
public static java.lang.String toString(@PolyAll java.lang.Object[] a,
boolean quoted)
a - an arrayquoted - whether to quote the array elementsAbstractCollection.toString()@SideEffectFree public static java.lang.String toString(@Nullable java.util.Collection<?> a)
a - a collectionAbstractCollection.toString()@SideEffectFree public static java.lang.String toStringQuoted(@Nullable java.util.Collection<?> a)
a - a collectionAbstractCollection.toString()@SideEffectFree
public static java.lang.String toString(@Nullable java.util.Collection<?> a,
boolean quoted)
a - a collectionquoted - whether to quote the collection elements that are Java stringsAbstractCollection.toString()@Pure public static boolean sorted(int[] a)
a - an array@Pure public static boolean sorted(long[] a)
a - an array@Pure public static boolean isSortedDescending(int[] a)
a - an array@Pure public static boolean isSortedDescending(long[] a)
a - an array@Pure public static boolean noDuplicates(boolean[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(byte[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(char[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(float[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(short[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(int[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(double[] a)
Double.equals(java.lang.Object).
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(long[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(java.lang.String[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static boolean noDuplicates(java.lang.Object[] a)
The implementation uses O(n) time and O(n) space.
a - an array@Pure public static <T> boolean noDuplicates(java.util.List<T> a)
The implementation uses O(n) time and O(n) space.
T - the type of the elementsa - a list@Pure public static boolean fnIsPermutation(int[] a)
a - an array, representing a function@Pure public static boolean fnIsTotal(int[] a)
a - an array, representing a functionpublic static int[] fnIdentity(int length)
length - the length of the resultpublic static int[] fnInversePermutation(int[] a)
a - the input permutationfnIsPermutation(int[])public static int[] fnInverse(int[] a,
int arange)
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 domainjava.lang.IllegalArgumentException - if a value of a is outside of arangejava.lang.UnsupportedOperationException - when the function is not invertiblepublic static @PolyAll int[] fnCompose(int[] a,
@PolyAll int[] b)
a - function from [0..a.length) to [0..b.length)b - function from [0..b.length) to range Rpublic static int[] partialFnCompose(int[] a,
int[] b)
a - function from [0..a.length) to [-1..b.length)b - function from [0..b.length) to range R@Pure
public static boolean isSubset(long[] smaller,
long[] bigger)
The implementation is to use collections because we want to take advantage of HashSet's constant time membership tests.
smaller - first set to testbigger - second set to test@Pure
public static boolean isSubset(double[] smaller,
double[] bigger)
The implementation is to use collections because we want to take advantage of HashSet's constant time membership tests.
smaller - first set to testbigger - second set to test@Pure
public static boolean isSubset(java.lang.String[] smaller,
java.lang.String[] bigger)
The implementation is to use collections because we want to take advantage of HashSet's constant time membership tests.
smaller - first set to testbigger - second set to test@Pure public static boolean anyNull(@PolyAll java.lang.Object[] a)
a - an array@Pure public static boolean allNull(@PolyAll java.lang.Object[] a)
a - an array@Pure public static boolean anyNull(java.util.List<?> a)
a - an array@Pure public static boolean allNull(java.util.List<?> a)
a - an arraypublic static <T> java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> partitionInto(java.util.Collection<T> elts,
int k)
List<List<T>>, where the union of the inner lists is elts. This method returns a list
of such partitionings.T - type of items to be partitionedelts - items to be partitionedk - number of subsets into which to partition eltspublic static <T> java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> partitionInto(java.util.Queue<T> elts,
int k)
List<List<T>>, where the union of the inner lists is elts. This method returns a list
of such partitionings.T - type of items to be partitionedelts - items to be partitionedk - number of subsets into which to partition eltspublic static <T> java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> partitionIntoHelper(java.util.Queue<T> elts,
java.util.List<org.plumelib.util.ArraysPlume.Partitioning<T>> resultSoFar,
int numEmptyParts,
int numNonemptyParts)
partitionInto(java.util.Collection<T>, int).T - type of items to be partitionedelts - the elements that remain to be added to the partitioningsresultSoFar - a list of partitionings, each of which has numNonemptyParts partsnumEmptyParts - the number of partitions in the partitioning that are empty so farnumNonemptyParts - the number of partitions in the partitioning that have at least one
member so far