public class Collections extends Object
Modifier and Type | Field and Description |
---|---|
static List |
EMPTY_LIST |
static Map |
EMPTY_MAP |
static Set |
EMPTY_SET |
Constructor and Description |
---|
Collections() |
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
addAll(Collection<? super T> c,
T... a) |
static <T> int |
binarySearch(List<? extends Comparable<? super T>> sortedList,
T key)
Perform a binary search on a sorted List, using natural ordering.
|
static <T> int |
binarySearch(List<? extends T> sortedList,
T key,
Comparator<? super T> comparator)
Perform a binary search on a sorted List, using a user-specified comparison
function.
|
static <T> void |
copy(List<? super T> dest,
List<? extends T> src) |
static boolean |
disjoint(Collection<?> c1,
Collection<?> c2) |
static <T> List<T> |
emptyList() |
static <K,V> Map<K,V> |
emptyMap() |
static <T> Set<T> |
emptySet() |
static <T> Enumeration<T> |
enumeration(Collection<T> c) |
static <T> void |
fill(List<? super T> list,
T obj) |
static int |
frequency(Collection<?> c,
Object o) |
static <T> ArrayList<T> |
list(Enumeration<T> e) |
static <T extends Object & Comparable<? super T>> |
max(Collection<? extends T> coll) |
static <T> T |
max(Collection<? extends T> coll,
Comparator<? super T> comp) |
static <T extends Object & Comparable<? super T>> |
min(Collection<? extends T> coll) |
static <T> T |
min(Collection<? extends T> coll,
Comparator<? super T> comp) |
static <T> List<T> |
nCopies(int n,
T o) |
static <T> boolean |
replaceAll(List<T> list,
T oldVal,
T newVal) |
static <T> void |
reverse(List<T> l) |
static <T> Comparator<T> |
reverseOrder() |
static <T> Comparator<T> |
reverseOrder(Comparator<T> cmp) |
static <T> Set<T> |
singleton(T o) |
static <T> List<T> |
singletonList(T o) |
static <K,V> Map<K,V> |
singletonMap(K key,
V value) |
static <T> void |
sort(List<T> target) |
static <T> void |
sort(List<T> target,
Comparator<? super T> c) |
static void |
swap(List<?> list,
int i,
int j) |
static <T> Collection<T> |
unmodifiableCollection(Collection<? extends T> coll) |
static <T> List<T> |
unmodifiableList(List<? extends T> list) |
static <K,V> Map<K,V> |
unmodifiableMap(Map<? extends K,? extends V> map) |
static <T> Set<T> |
unmodifiableSet(Set<? extends T> set) |
static <K,V> SortedMap<K,V> |
unmodifiableSortedMap(SortedMap<K,? extends V> map) |
static <T> SortedSet<T> |
unmodifiableSortedSet(SortedSet<? extends T> set) |
public static final List EMPTY_LIST
public static final Map EMPTY_MAP
public static final Set EMPTY_SET
public static <T> boolean addAll(Collection<? super T> c, T... a)
public static <T> int binarySearch(List<? extends Comparable<? super T>> sortedList, T key)
Note: The GWT implementation differs from the JDK implementation in that it does not do an iterator-based binary search for Lists that do not implement RandomAccess.
sortedList
- object array to searchkey
- value to search forClassCastException
- if key
is not comparable to
sortedList
's elements.public static <T> int binarySearch(List<? extends T> sortedList, T key, Comparator<? super T> comparator)
Note: The GWT implementation differs from the JDK implementation in that it does not do an iterator-based binary search for Lists that do not implement RandomAccess.
sortedList
- List to searchkey
- value to search forcomparator
- comparision function, null
indicates
natural ordering should be used.ClassCastException
- if key
and
sortedList
's elements cannot be compared by
comparator
.public static boolean disjoint(Collection<?> c1, Collection<?> c2)
public static <T> List<T> emptyList()
public static <K,V> Map<K,V> emptyMap()
public static <T> Set<T> emptySet()
public static <T> Enumeration<T> enumeration(Collection<T> c)
public static <T> void fill(List<? super T> list, T obj)
public static int frequency(Collection<?> c, Object o)
public static <T> ArrayList<T> list(Enumeration<T> e)
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp)
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll)
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
public static <T> List<T> nCopies(int n, T o)
public static <T> boolean replaceAll(List<T> list, T oldVal, T newVal)
public static <T> void reverse(List<T> l)
public static <T> Comparator<T> reverseOrder()
public static <T> Comparator<T> reverseOrder(Comparator<T> cmp)
public static <T> Set<T> singleton(T o)
public static <T> List<T> singletonList(T o)
public static <K,V> Map<K,V> singletonMap(K key, V value)
public static <T> void sort(List<T> target)
public static <T> void sort(List<T> target, Comparator<? super T> c)
public static void swap(List<?> list, int i, int j)
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> coll)
public static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K,? extends V> map)
Copyright © 2018. All rights reserved.