public final class CollectionUtil
extends java.lang.Object
java.util.collection-related utility methods.| Modifier and Type | Field and Description |
|---|---|
static java.util.Iterator |
AT_END
An iterator which is at its end.
|
static java.util.SortedMap |
EMPTY_SORTED_MAP
Desperately missing from
java.util.Collections. |
static java.util.SortedSet |
EMPTY_SORTED_SET
Desperately missing from
java.util.Collections. |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> java.util.SortedMap<K,V> |
emptySortedMap()
Desperately missing from
java.util.Collections. |
static <T> java.util.SortedSet<T> |
emptySortedSet()
Desperately missing from
java.util.Collections. |
static <K,V> java.util.Map<K,V> |
map(K[] keys,
V[] values)
Returns an unmodifiable map, mapping the given key-value pairs.
|
static <K,V> java.util.Map<K,V> |
map(java.lang.Object... keyValuePairs)
Returns an unmodifiable map, mapping the given key-value pairs.
|
static <T> T |
removeFirstFrom(java.util.Collection<T> subject)
Removes and returns the first element of the given collection.
|
static <T> java.util.Collection<T> |
sorted(java.util.Collection<T> collection)
Returns an unmodifiable collection containing the elements of the given collection, but sorted by
their "natural ordering".
|
public static final java.util.SortedMap EMPTY_SORTED_MAP
java.util.Collections.public static final java.util.SortedSet EMPTY_SORTED_SET
java.util.Collections.public static final java.util.Iterator AT_END
@Nullable public static <T> T removeFirstFrom(java.util.Collection<T> subject)
null iff the collection is emptypublic static <K,V> java.util.Map<K,V> map(java.lang.Object... keyValuePairs)
null keys and null values are
supported.keyValuePairs - An alternating sequence of keys and valuesjava.lang.ArrayIndexOutOfBoundsException - The length of keyValuePairs is oddjava.lang.IllegalArgumentException - Two of the keys are equalpublic static <K,V> java.util.Map<K,V> map(K[] keys,
V[] values)
null keys and null values are
supported.java.lang.ArrayIndexOutOfBoundsException - The length of keyValuePairs is oddjava.lang.IllegalArgumentException - Two of the keys are equalpublic static <K,V> java.util.SortedMap<K,V> emptySortedMap()
java.util.Collections.public static <T> java.util.SortedSet<T> emptySortedSet()
java.util.Collections.public static <T> java.util.Collection<T> sorted(java.util.Collection<T> collection)