java.util
Class Collections

java.lang.Object
  extended by java.util.Collections


public class Collections
extends Object


Field Summary
static List EMPTY_LIST
           
static Map EMPTY_MAP
           
static Set EMPTY_SET
           
 
Method Summary
static
<T> boolean
addAll(Collection<? super T> c, T... a)
           
static
<T> int
binarySearch(List<? extends Comparable<? super T>> list, T key)
           
static
<T> int
binarySearch(List<? extends T> list, T key, Comparator<? super T> c)
           
static
<E> Collection<E>
checkedCollection(Collection<E> c, Class<E> type)
           
static
<E> List<E>
checkedList(List<E> list, Class<E> type)
           
static
<K,V> Map<K,V>
checkedMap(Map<K,V> m, Class<K> keyType, Class<V> valueType)
           
static
<E> Set<E>
checkedSet(Set<E> s, Class<E> type)
           
static
<K,V> SortedMap<K,V>
checkedSortedMap(SortedMap<K,V> m, Class<K> keyType, Class<V> valueType)
           
static
<E> SortedSet<E>
checkedSortedSet(SortedSet<E> s, Class<E> type)
           
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 int indexOfSubList(List<?> source, List<?> target)
           
static int lastIndexOfSubList(List<?> source, List<?> target)
           
static
<T> ArrayList<T>
list(Enumeration<T> e)
           
static
<T extends Object & Comparable<? super T>>
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>>
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 void reverse(List<?> list)
           
static
<T> Comparator<T>
reverseOrder()
           
static
<T> Comparator<T>
reverseOrder(Comparator<T> cmp)
           
static void rotate(List<?> list, int distance)
           
static void shuffle(List<?> list)
           
static void shuffle(List<?> list, Random rnd)
           
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 extends Comparable<? super T>>
void
sort(List<T> list)
           
static
<T> void
sort(List<T> list, Comparator<? super T> c)
           
static void swap(List<?> list, int i, int j)
           
static
<T> Collection<T>
synchronizedCollection(Collection<T> c)
           
static
<T> List<T>
synchronizedList(List<T> list)
           
static
<K,V> Map<K,V>
synchronizedMap(Map<K,V> m)
           
static
<T> Set<T>
synchronizedSet(Set<T> s)
           
static
<K,V> SortedMap<K,V>
synchronizedSortedMap(SortedMap<K,V> m)
           
static
<T> SortedSet<T>
synchronizedSortedSet(SortedSet<T> s)
           
static
<T> Collection<T>
unmodifiableCollection(Collection<T> c)
           
static
<T> List<T>
unmodifiableList(List<T> list)
           
static
<K,V> Map<K,V>
unmodifiableMap(Map<K,V> m)
           
static
<T> Set<T>
unmodifiableSet(Set<T> s)
           
static
<K,V> SortedMap<K,V>
unmodifiableSortedMap(SortedMap<K,V> m)
           
static
<T> SortedSet<T>
unmodifiableSortedSet(SortedSet<T> s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_LIST

public static final List EMPTY_LIST

EMPTY_MAP

public static final Map EMPTY_MAP

EMPTY_SET

public static final Set EMPTY_SET
Method Detail

binarySearch

public static <T> int binarySearch(List<? extends Comparable<? super T>> list,
                                   T key)

binarySearch

public static <T> int binarySearch(List<? extends T> list,
                                   T key,
                                   Comparator<? super T> c)

copy

public static <T> void copy(List<? super T> dest,
                            List<? extends T> src)

enumeration

public static <T> Enumeration<T> enumeration(Collection<T> c)

fill

public static <T> void fill(List<? super T> list,
                            T obj)

indexOfSubList

public static int indexOfSubList(List<?> source,
                                 List<?> target)

lastIndexOfSubList

public static int lastIndexOfSubList(List<?> source,
                                     List<?> target)

list

public static <T> ArrayList<T> list(Enumeration<T> e)

max

public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)

max

public static <T> T max(Collection<? extends T> coll,
                        Comparator<? super T> comp)

min

public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll)

min

public static <T> T min(Collection<? extends T> coll,
                        Comparator<? super T> comp)

nCopies

public static <T> List<T> nCopies(int n,
                                  T o)

replaceAll

public static <T> boolean replaceAll(List<T> list,
                                     T oldVal,
                                     T newVal)

reverse

public static void reverse(List<?> list)

reverseOrder

public static <T> Comparator<T> reverseOrder()

rotate

public static void rotate(List<?> list,
                          int distance)

shuffle

public static void shuffle(List<?> list)

shuffle

public static void shuffle(List<?> list,
                           Random rnd)

singleton

public static <T> Set<T> singleton(T o)

singletonList

public static <T> List<T> singletonList(T o)

singletonMap

public static <K,V> Map<K,V> singletonMap(K key,
                                          V value)

sort

public static <T extends Comparable<? super T>> void sort(List<T> list)

sort

public static <T> void sort(List<T> list,
                            Comparator<? super T> c)

swap

public static void swap(List<?> list,
                        int i,
                        int j)

synchronizedCollection

public static <T> Collection<T> synchronizedCollection(Collection<T> c)

synchronizedList

public static <T> List<T> synchronizedList(List<T> list)

synchronizedMap

public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m)

synchronizedSet

public static <T> Set<T> synchronizedSet(Set<T> s)

synchronizedSortedMap

public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m)

synchronizedSortedSet

public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s)

unmodifiableCollection

public static <T> Collection<T> unmodifiableCollection(Collection<T> c)

unmodifiableList

public static <T> List<T> unmodifiableList(List<T> list)

unmodifiableMap

public static <K,V> Map<K,V> unmodifiableMap(Map<K,V> m)

unmodifiableSet

public static <T> Set<T> unmodifiableSet(Set<T> s)

unmodifiableSortedMap

public static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K,V> m)

unmodifiableSortedSet

public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> s)

checkedCollection

public static <E> Collection<E> checkedCollection(Collection<E> c,
                                                  Class<E> type)

checkedSet

public static <E> Set<E> checkedSet(Set<E> s,
                                    Class<E> type)

checkedSortedSet

public static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s,
                                                Class<E> type)

checkedList

public static <E> List<E> checkedList(List<E> list,
                                      Class<E> type)

checkedMap

public static <K,V> Map<K,V> checkedMap(Map<K,V> m,
                                        Class<K> keyType,
                                        Class<V> valueType)

checkedSortedMap

public static <K,V> SortedMap<K,V> checkedSortedMap(SortedMap<K,V> m,
                                                    Class<K> keyType,
                                                    Class<V> valueType)

emptySet

public static final <T> Set<T> emptySet()

emptyList

public static final <T> List<T> emptyList()

emptyMap

public static final <K,V> Map<K,V> emptyMap()

reverseOrder

public static <T> Comparator<T> reverseOrder(Comparator<T> cmp)

frequency

public static int frequency(Collection<?> c,
                            Object o)

disjoint

public static boolean disjoint(Collection<?> c1,
                               Collection<?> c2)

addAll

public static <T> boolean addAll(Collection<? super T> c,
                                 T... a)