public final class CollectionUtil extends PrimitiveSort
Collection
and
List
.Modifier and Type | Method and Description |
---|---|
static <C extends Collection<T>,T> |
asCollection(C c,
T[] a)
Returns the specified collection with the provided parameters array added
as members to the collection.
|
static <C extends Collection<T>,T> |
asCollection(C c,
T[] a,
int fromIndex,
int toIndex)
Returns the specified collection with the provided array of members added
to the collection.
|
static <C extends Collection<T>,T> |
asCollection(C c,
T a0,
T... an)
Returns the specified collection with the provided vararg parameters added
as members to the collection.
|
static int |
binaryClosestSearch(ArrayDoubleList a,
double key)
Find the index of the sorted
ArrayDoubleList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayDoubleList a,
double key,
DoubleComparator c)
Find the index of the sorted
ArrayDoubleList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayDoubleList a,
int fromIndex,
int toIndex,
double key)
Find the index of the sorted
ArrayDoubleList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayDoubleList a,
int fromIndex,
int toIndex,
double key,
DoubleComparator c)
Find the index of the sorted
ArrayDoubleList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayFloatList a,
float key)
Find the index of the sorted
ArrayFloatList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayFloatList a,
float key,
FloatComparator c)
Find the index of the sorted
ArrayFloatList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayFloatList a,
int fromIndex,
int toIndex,
float key)
Find the index of the sorted
ArrayFloatList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayFloatList a,
int fromIndex,
int toIndex,
float key,
FloatComparator c)
Find the index of the sorted
ArrayFloatList whose value most
closely matches the value provided. |
static int |
binaryClosestSearch(ArrayIntList a,
int key)
Find the index of the sorted
ArrayIntList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayIntList a,
int key,
IntComparator c)
Find the index of the sorted
ArrayIntList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayIntList a,
int fromIndex,
int toIndex,
int key)
Find the index of the sorted
ArrayIntList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayIntList a,
int fromIndex,
int toIndex,
int key,
IntComparator c)
Find the index of the sorted
ArrayIntList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayLongList a,
int fromIndex,
int toIndex,
long key)
Find the index of the sorted
ArrayLongList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayLongList a,
int fromIndex,
int toIndex,
long key,
LongComparator c)
Find the index of the sorted
ArrayLongList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayLongList a,
long key)
Find the index of the sorted
ArrayLongList whose value most closely
matches the value provided. |
static int |
binaryClosestSearch(ArrayLongList a,
long key,
LongComparator c)
Find the index of the sorted
ArrayLongList whose value most closely
matches the value provided. |
static <T extends Comparable<? super T>> |
binaryClosestSearch(List<? extends T> a,
int fromIndex,
int toIndex,
T key)
Find the index of the sorted
List whose value most closely matches
the value provided. |
static <T> int |
binaryClosestSearch(List<? extends T> a,
int fromIndex,
int toIndex,
T key,
Comparator<? super T> c)
Find the index of the sorted
List whose value most closely matches
the value provided. |
static <T extends Comparable<? super T>> |
binaryClosestSearch(List<? extends T> a,
T key)
Find the index of the sorted
List whose value most closely matches
the value provided. |
static <T> int |
binaryClosestSearch(List<? extends T> a,
T key,
Comparator<? super T> c)
Find the index of the sorted
List whose value most closely matches
the value provided. |
static <T extends Comparable<? super T>> |
binarySearch(List<? extends T> a,
int fromIndex,
int toIndex,
T key)
Searches a range of the specified list for the specified object using the
binary search algorithm.
|
static <T> int |
binarySearch(List<? extends T> a,
int fromIndex,
int toIndex,
T key,
Comparator<? super T> c)
Searches a range of the specified list for the specified object using the
binary search algorithm.
|
static <T extends Comparable<? super T>> |
binarySearch(List<? extends T> a,
T key)
Searches the specified list for the specified object using the binary
search algorithm.
|
static <T> int |
binarySearch(List<? extends T> a,
T key,
Comparator<? super T> c)
Searches the specified list for the specified object using the binary
search algorithm.
|
static <C extends Collection<T>,T> |
concat(C target,
Collection<? extends T>... collections)
Returns the specified target collection with the elements of the specified
vararg parameter collections concatenated as members to the target
collection.
|
static <C extends Collection<T>,T> |
flatten(Collection<? extends T> in,
C out,
Function<T,? extends Collection<T>> resolver,
boolean retainCollectionReferences)
Inserts the one-dimensional representation of the input collection into the
specified output collection, whereby all nested
Collection members
are flattened at every depth. |
static <C extends Collection<T>,T> |
flatten(Collection<T> in,
C out)
Inserts the one-dimensional representation of the input collection into the
specified output collection, whereby all nested
Collection members
are flattened at every depth. |
static <C extends Collection<T>,T> |
flatten(Collection<T> in,
C out,
boolean retainCollectionReferences)
Inserts the one-dimensional representation of the input collection into the
specified output collection, whereby all nested
Collection members
are flattened at every depth. |
static <L extends List<T>,T> |
flatten(L list)
Flattens the specified list into a one-dimensional representation,
in-place, replacing all nested
List members with their expanded
form, at every depth. |
static <L extends List<T>,T> |
flatten(L list,
boolean retainListReferences)
Flattens the specified list into a one-dimensional representation,
in-place, replacing all nested
List members with their expanded
form, at every depth. |
static <L extends List<T>,T> |
flatten(L list,
Function<T,? extends List<T>> resolver,
boolean retainListReferences)
Flattens the specified list into a one-dimensional representation,
in-place, replacing all nested
List members with their expanded
form, at every depth. |
static Class<?> |
getComponentType(Collection<?> c)
Returns a class representing the component type of the specified
collection.
|
static boolean |
isComponentType(Collection<?> c,
Class<?> type)
Returns
true if the specified class is instance-assignable for each
member object of the specified collection, otherwise false . |
static <T> List<T>[] |
partition(List<T> list,
int size)
Returns an array of sublists of the specified list partitioned to the
specified size.
|
static void |
sort(List<?> data,
byte[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
byte[] order,
ByteComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
char[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
char[] order,
CharComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
double[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
double[] order,
DoubleComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
float[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
float[] order,
FloatComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
int[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
int[] order,
IntComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static <T> void |
sort(List<?> data,
List<? extends T> order,
Comparator<? super T> comparator)
|
static <T extends Comparable<? super T>> |
sort(List<?> data,
List<T> order)
Sorts the
List in the first argument matching the sorted order of
the List of Comparable objects in the second argument. |
static void |
sort(List<?> data,
long[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
long[] order,
LongComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
short[] order)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static void |
sort(List<?> data,
short[] order,
ShortComparator comparator)
Sorts the
List in the first argument matching the sorted order of
the array in the second argument. |
static String |
toString(Collection<?> c,
char del)
Returns a string representation of the specified collection, using the
specified delimiter between the string representation of each element.
|
static String |
toString(Collection<?> c,
String del)
Returns a string representation of the specified collection, using the
specified delimiter between the string representation of each element.
|
buildIndex, sort, sort, sort, sort, sort, sort, sort, sortIndexed, sortIndexed, sortPaired, sortPaired, sortPaired, sortPaired, sortPaired, sortPaired, sortPaired
public static <C extends Collection<T>,T> C flatten(Collection<T> in, C out)
Collection
members
are flattened at every depth. The value of
member instanceof Collection
is used to determine whether a member
represents a Collection
for further recursion.
Collection members that reference a Collection
are not
included in the resulting collection. This is the equivalent of calling
flatten(Collection,Collection,false)
.
C
- The type of the output collection.T
- The type of collection elements.in
- The input collection.out
- The output collection.NullPointerException
- If in
or out
is null.public static <C extends Collection<T>,T> C flatten(Collection<T> in, C out, boolean retainCollectionReferences)
Collection
members
are flattened at every depth.C
- The type of the output collection.T
- The type of collection elements.in
- The input collection.out
- The output collection.retainCollectionReferences
- If true
, members that reference a
Collection
are included in the output collection; if
false
, they are not included in the output collection.NullPointerException
- If in
or out
is null.public static <C extends Collection<T>,T> C flatten(Collection<? extends T> in, C out, Function<T,? extends Collection<T>> resolver, boolean retainCollectionReferences)
Collection
members
are flattened at every depth. The specified resolver Function
provides a layer of indirection between a member, and a higher-layer value.
This is useful in the situation where the collection contains symbolic
references to other collections. The resolver
parameter is provided
to dereference such a symbolic references.C
- The type of the output collection.T
- The type of collection elements.in
- The input collection.out
- The output collection.resolver
- A Function
to provide a layer of indirection
between a member, and a higher-layer value. If resolver
is
null, member instanceof Collection
is used to determine
whether the member value represents a collection.retainCollectionReferences
- If true
, members that reference a
Collection
are included in the output collection; if
false
, they are not included in the output collection.NullPointerException
- If in
or out
is null.public static <L extends List<T>,T> L flatten(L list)
List
members with their expanded
form, at every depth. The value of member instanceof List
is used
to determine whether a member represents a List
for further
recursion.
List members that reference a List
are not included in the
resulting array. This is the equivalent of calling
flatten(List,false)
.
L
- The type of the list.T
- The type of list elements.list
- The list.NullPointerException
- If list
is null.public static <L extends List<T>,T> L flatten(L list, boolean retainListReferences)
List
members with their expanded
form, at every depth.L
- The type of the list.T
- The type of list elements.list
- The list.retainListReferences
- If true
, members that reference a
List
are retained; if false
, they are removed.NullPointerException
- If list
is null.public static <L extends List<T>,T> L flatten(L list, Function<T,? extends List<T>> resolver, boolean retainListReferences)
List
members with their expanded
form, at every depth. The specified resolver Function
provides a
layer of indirection between a member, and a higher-layer value. This is
useful in the situation where the collection contains symbolic references
to other list. The resolver
parameter is provided to dereference
such a symbolic references.L
- The type of the list.T
- The type of list elements.list
- The list.retainListReferences
- If true
, members that reference a
List
are retained; if false
, they are removed.resolver
- A Function
to provide a layer of indirection
between a member, and a higher-layer value. If resolver
is
null, member instanceof List
is used to determine whether
the member value represents a list.NullPointerException
- If list
is null.public static Class<?> getComponentType(Collection<?> c)
c
- The collection.null
if the collection has no member
objects.NullPointerException
- If the specified collection is null.public static boolean isComponentType(Collection<?> c, Class<?> type)
true
if the specified class is instance-assignable for each
member object of the specified collection, otherwise false
.c
- The collection.type
- The class.true
if the specified class is instance-assignable for each
member object of the specified collection, otherwise false
.NullPointerException
- If c
or type
is null.public static String toString(Collection<?> c, char del)
"null"
. If the specified collection is empty, this method returns
""
.c
- The collection.del
- The delimiter.NullPointerException
- If the specified collection is null.public static String toString(Collection<?> c, String del)
"null"
. If the specified collection is empty, this method returns
""
.c
- The collection.del
- The delimiter.NullPointerException
- If the specified collection is null.public static <T extends Comparable<? super T>> int binarySearch(List<? extends T> a, int fromIndex, int toIndex, T key)
List.sort(Comparator)
method) prior to making this call.
If it is not sorted, the results are undefined. (If the range contains
elements that are not mutually comparable (for example, strings and
integers), it cannot be sorted according to the natural ordering of
its elements, hence results are undefined.) If the range contains multiple
elements equal to the specified object, there is no guarantee which one
will be found.T
- Type parameter of Comparable key object.a
- The list to be searched.fromIndex
- The index of the first element (inclusive) to be searched.toIndex
- The index of the last element (exclusive) to be searched.key
- The value to be searched for.(-(<i>insertion point</i>) - 1)
.
The insertion point is defined as the point at which the key
would be inserted into the list: the index of the first element in
the range greater than the key, or toIndex
if all elements
in the range are less than the specified key. Note that this
guarantees that the return value will be >= 0
if and only
if the key is found.ClassCastException
- If the search key is not comparable to the
elements of the list within the specified range.IllegalArgumentException
- If fromIndex > toIndex
ArrayIndexOutOfBoundsException
- If fromIndex < 0
or
toIndex > a.length
NullPointerException
- If a
is null.public static <T extends Comparable<? super T>> int binarySearch(List<? extends T> a, T key)
List.sort(Comparator)
method) prior to making this call. If it is
not sorted, the results are undefined. (If the list contains elements that
are not mutually comparable (for example, strings and integers), it
cannot be sorted according to the natural ordering of its elements,
hence results are undefined.) If the list contains multiple elements equal
to the specified object, there is no guarantee which one will be found.T
- Type parameter of Comparable key object.a
- The list to be searched.key
- The value to be searched for.(-(<i>insertion point</i>) - 1)
. The insertion point
is defined as the point at which the key would be inserted into the
list: the index of the first element greater than the key, or
a.length
if all elements in the list are less than the
specified key. Note that this guarantees that the return value will
be >= 0
if and only if the key is found.ClassCastException
- If the search key is not comparable to the
elements of the array.NullPointerException
- If a
is null.public static <T> int binarySearch(List<? extends T> a, int fromIndex, int toIndex, T key, Comparator<? super T> c)
List.sort(Comparator)
method) prior to making this call. If it is
not sorted, the results are undefined. If the range contains multiple
elements equal to the specified object, there is no guarantee which one
will be found.T
- The type parameter of the Comparable key object.a
- The list to be searched.fromIndex
- The index of the first element (inclusive) to be searched.toIndex
- The index of the last element (exclusive) to be searched.key
- The value to be searched for.c
- The comparator by which the list is ordered. A null
value
indicates that the elements' natural
ordering should be used.(-(<i>insertion point</i>) - 1)
.
The insertion point is defined as the point at which the key
would be inserted into the list: the index of the first element in
the range greater than the key, or toIndex
if all elements
in the range are less than the specified key. Note that this
guarantees that the return value will be >= 0
if and only
if the key is found.ClassCastException
- If the range contains elements that are not
mutually comparable using the specified comparator, or the
search key is not comparable to the elements in the range using
this comparator.IllegalArgumentException
- If fromIndex > toIndex
ArrayIndexOutOfBoundsException
- If fromIndex < 0
or
toIndex > a.length
NullPointerException
- If a
or c
is null.public static <T> int binarySearch(List<? extends T> a, T key, Comparator<? super T> c)
List.sort(Comparator)
method)
prior to making this call. If it is not sorted, the results are undefined.
If the list contains multiple elements equal to the specified object, there
is no guarantee which one will be found.T
- The type parameter of the Comparable key object.a
- The list to be searched.key
- The value to be searched for.c
- The comparator by which the list is ordered. A null
value
indicates that the elements' natural
ordering should be used.(-(<i>insertion point</i>) - 1)
. The insertion point
is defined as the point at which the key would be inserted into the
list: the index of the first element greater than the key, or
a.length
if all elements in the list are less than the
specified key. Note that this guarantees that the return value will
be >= 0
if and only if the key is found.ClassCastException
- If the list contains elements that are not
mutually comparable using the specified comparator, or the
search key is not comparable to the elements of the list using
this comparator.NullPointerException
- If a
or c
is null.public static <T extends Comparable<? super T>> int binaryClosestSearch(List<? extends T> a, T key)
List
whose value most closely matches
the value provided.T
- The type parameter of the Comparable key object.a
- The sorted List
.key
- The value to match.List
matching the desired
value.NullPointerException
- If a
is null.public static <T extends Comparable<? super T>> int binaryClosestSearch(List<? extends T> a, int fromIndex, int toIndex, T key)
List
whose value most closely matches
the value provided.T
- The type parameter of the Comparable key object.a
- The sorted List
.fromIndex
- The starting index of the sorted List
to search
from.toIndex
- The ending index of the sorted List
to search to.key
- The value to match.List
matching the desired
value.NullPointerException
- If a
is null.public static <T> int binaryClosestSearch(List<? extends T> a, T key, Comparator<? super T> c)
List
whose value most closely matches
the value provided.T
- The type parameter of the key object.a
- The sorted List
.key
- The value to match.c
- The Comparator
for key
of type <T>
.List
matching the desired
value.NullPointerException
- If a
or c
is null.public static <T> int binaryClosestSearch(List<? extends T> a, int fromIndex, int toIndex, T key, Comparator<? super T> c)
List
whose value most closely matches
the value provided.T
- The type parameter of the key object.a
- The sorted List
.fromIndex
- The starting index of the sorted List
to search
from.toIndex
- The ending index of the sorted List
to search to.key
- The value to match.c
- The Comparator
for key
of type <T>
.List
matching the desired
value.NullPointerException
- If a
or c
is null.public static int binaryClosestSearch(ArrayIntList a, int key)
ArrayIntList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayIntList
.key
- The value to match.ArrayIntList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayIntList
is null.public static int binaryClosestSearch(ArrayIntList a, int key, IntComparator c)
ArrayIntList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayIntList
.key
- The value to match.c
- The comparator to use.ArrayIntList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayIntList
is null.public static int binaryClosestSearch(ArrayIntList a, int fromIndex, int toIndex, int key)
ArrayIntList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayIntList
.fromIndex
- The starting index of the ArrayIntList
to search
from.toIndex
- The ending index of the ArrayIntList
to search to.key
- The value to match.ArrayIntList
matching the desired
value. The returned index will be less than or equal to an exact
match.NullPointerException
- If the specified ArrayIntList
is null.public static int binaryClosestSearch(ArrayIntList a, int fromIndex, int toIndex, int key, IntComparator c)
ArrayIntList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayIntList
.fromIndex
- The starting index of the ArrayIntList
to search
from.toIndex
- The ending index of the ArrayIntList
to search to.key
- The value to match.c
- The comparator to use.ArrayIntList
matching the desired
value. The returned index will be less than or equal to an exact
match.NullPointerException
- If the specified array is null.public static int binaryClosestSearch(ArrayLongList a, long key)
ArrayLongList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayLongList
.key
- The value to match.ArrayLongList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayLongList
is
null.public static int binaryClosestSearch(ArrayLongList a, long key, LongComparator c)
ArrayLongList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayLongList
.key
- The value to match.c
- The comparator to use.ArrayLongList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayLongList
is
null.public static int binaryClosestSearch(ArrayLongList a, int fromIndex, int toIndex, long key)
ArrayLongList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match. The returned index will be less than or equal to an
exact match.a
- The sorted ArrayLongList
.fromIndex
- The starting index of the ArrayLongList
to search
from.toIndex
- The ending index of the ArrayLongList
to search to.key
- The value to match.ArrayLongList
matching the desired
value. The returned index will be less than or equal to an exact
match.NullPointerException
- If the specified ArrayLongList
is
null.public static int binaryClosestSearch(ArrayLongList a, int fromIndex, int toIndex, long key, LongComparator c)
ArrayLongList
whose value most closely
matches the value provided. The returned index will be less than or equal
to an exact match.a
- The sorted ArrayLongList
.fromIndex
- The starting index of the ArrayLongList
to search
from.toIndex
- The ending index of the ArrayLongList
to search to.key
- The value to match.c
- The comparator to use.ArrayLongList
matching the desired
value. The returned index will be less than or equal to an exact
match.NullPointerException
- If the specified array is null.public static int binaryClosestSearch(ArrayFloatList a, float key)
ArrayFloatList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayFloatList
.key
- The value to match.ArrayFloatList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayFloatList
is
null.public static int binaryClosestSearch(ArrayFloatList a, float key, FloatComparator c)
ArrayFloatList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayFloatList
.key
- The value to match.c
- The comparator to use.ArrayFloatList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayFloatList
is
null.public static int binaryClosestSearch(ArrayFloatList a, int fromIndex, int toIndex, float key)
ArrayFloatList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayFloatList
.fromIndex
- The starting index of the ArrayFloatList
to search
from.toIndex
- The ending index of the ArrayFloatList
to search to.key
- The value to match.ArrayFloatList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayFloatList
is
null.public static int binaryClosestSearch(ArrayFloatList a, int fromIndex, int toIndex, float key, FloatComparator c)
ArrayFloatList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayFloatList
.fromIndex
- The starting index of the ArrayFloatList
to search
from.toIndex
- The ending index of the ArrayFloatList
to search to.key
- The value to match.c
- The comparator to use.ArrayFloatList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified array is null.public static int binaryClosestSearch(ArrayDoubleList a, double key)
ArrayDoubleList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayDoubleList
.key
- The value to match.ArrayDoubleList
matching
the desired value. The returned index will be less than or equal to
an exact match.NullPointerException
- If the specified ArrayDoubleList
is
null.public static int binaryClosestSearch(ArrayDoubleList a, double key, DoubleComparator c)
ArrayDoubleList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayDoubleList
.key
- The value to match.c
- The comparator to use.ArrayDoubleList
matching
the desired value. The returned index will be less than or equal to
an exact match.NullPointerException
- If the specified ArrayDoubleList
is
null.public static int binaryClosestSearch(ArrayDoubleList a, int fromIndex, int toIndex, double key)
ArrayDoubleList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayDoubleList
.fromIndex
- The starting index of the ArrayDoubleList
to
search from.toIndex
- The ending index of the ArrayDoubleList
to search
to.key
- The value to match.ArrayDoubleList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified ArrayDoubleList
is
null.public static int binaryClosestSearch(ArrayDoubleList a, int fromIndex, int toIndex, double key, DoubleComparator c)
ArrayDoubleList
whose value most
closely matches the value provided. The returned index will be less than or
equal to an exact match.a
- The sorted ArrayDoubleList
.fromIndex
- The starting index of the ArrayDoubleList
to
search from.toIndex
- The ending index of the ArrayDoubleList
to search
to.key
- The value to match.c
- The comparator to use.ArrayDoubleList
matching the
desired value. The returned index will be less than or equal to an
exact match.NullPointerException
- If the specified array is null.public static <C extends Collection<T>,T> C asCollection(C c, T[] a)
C
- The type of the collection.T
- The type of collection elements.c
- The collection.a
- The members to add to the collection.NullPointerException
- If c
or a
is null.@SafeVarargs public static <C extends Collection<T>,T> C asCollection(C c, T a0, T... an)
C
- The type of the collection.T
- The type of collection elements.c
- The collection.a0
- The first member to add to the collection.an
- The remaining members to add to the collection.NullPointerException
- If c
or a
is null.public static <C extends Collection<T>,T> C asCollection(C c, T[] a, int fromIndex, int toIndex)
C
- The type of the collection.T
- The type of collection elements.c
- The collection.a
- The members to add to the collection.fromIndex
- The index of the first member (inclusive) to be added.toIndex
- The index of the last member (exclusive) to be added.IllegalArgumentException
- If fromIndex
is greater than
toIndex
.ArrayIndexOutOfBoundsException
- If fromIndex
is less than 0,
or if toIndex
is greater than the length of the specified
array.NullPointerException
- If c
or a
is null.@SafeVarargs public static <C extends Collection<T>,T> C concat(C target, Collection<? extends T>... collections)
C
- The type of the collection.T
- The type of collection elements.target
- The target collection.collections
- The collections of members to concatenate to the target
collection.NullPointerException
- If target
, collections
, or a
member element in collections
is null.public static <T> List<T>[] partition(List<T> list, int size)
1
to
size
.T
- The type of list elements.list
- The list to partition.size
- The size of each partition.IllegalArgumentException
- If size
is less than or equal to
0.NullPointerException
- If list
is null.public static void sort(List<?> data, byte[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, byte[] order, ByteComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, char[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, char[] order, CharComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, short[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, short[] order, ShortComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, int[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, int[] order, IntComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, long[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, long[] order, LongComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, float[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, float[] order, FloatComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, double[] order)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.length
.public static void sort(List<?> data, double[] order, DoubleComparator comparator)
List
in the first argument matching the sorted order of
the array in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
data
- The List
providing the data.order
- The array providing the order of indices to sort data
.comparator
- The comparator to use.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.length
.public static <T extends Comparable<? super T>> void sort(List<?> data, List<T> order)
List
in the first argument matching the sorted order of
the List
of Comparable
objects in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
T
- The type parameter for the Comparable
objects of
order
.data
- The List
providing the data.order
- The List
of Comparable
objects providing the
order of indices to sort data
.NullPointerException
- If data
or order
is null.IllegalArgumentException
- If data.size() != order.size()
.public static <T> void sort(List<?> data, List<? extends T> order, Comparator<? super T> comparator)
List
in the first argument matching the sorted order of
the List
in the second argument.
For example, data
and order
are initialized to:
data: g i j h e a c d b f order: 6 8 9 7 4 0 2 3 1 5After
sort(data, order)
is called:
data: a b c d e f g h i j order: 0 1 2 3 4 5 6 7 8 9
T
- The type parameter for the Comparable
objects of
order
.data
- The List
providing the data.order
- The List
providing the order of indices to sort
data
.comparator
- The Comparator
for members of order
.NullPointerException
- If data
, order
, or
comparator
is null.IllegalArgumentException
- If data.size() != order.size()
.Copyright © 2020 LibJ. All rights reserved.