API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util. Collections View Source
Author(s)
Josh Bloch
Neal Gafter
Since
1.2
Version
1.106, 04/21/06
Serial
Hierarchy
 Object
      Collections
Implements
Subclasses
Description
public class Collections
  This class consists exclusively of static methods that operate on or return collections.
See also:    Collection Set List Map
Constructors
private Collections ()
Methods
Hide/Show inherited methods
publicstatic boolean addAll (Collection<Object> c, T elements)
  Adds all of the specified elements to the specified collection.
publicstatic Queue< T> asLifoQueue (Deque< T> deque)
  Returns a view of a Deque as a Last-in-first-out (Lifo) Queue.
publicstatic int binarySearch (List<Comparable> list, T key)
  Searches the specified list for the specified object using the binary search algorithm.
publicstatic int binarySearch (List<Object> list, T key, Comparator<Object> c)
  Searches the specified list for the specified object using the binary search algorithm.
publicstatic Collection< E> checkedCollection (Collection< E> c, Class< E> type)
  Returns a dynamically typesafe view of the specified collection.
publicstatic List< E> checkedList (List< E> list, Class< E> type)
  Returns a dynamically typesafe view of the specified list.
publicstatic Map< K, V> checkedMap (Map< K, V> m, Class< K> keyType, Class< V> valueType)
  Returns a dynamically typesafe view of the specified map.
publicstatic Set< E> checkedSet (Set< E> s, Class< E> type)
  Returns a dynamically typesafe view of the specified set.
publicstatic SortedMap< K, V> checkedSortedMap (SortedMap< K, V> m, Class< K> keyType, Class< V> valueType)
  Returns a dynamically typesafe view of the specified sorted map.
publicstatic SortedSet< E> checkedSortedSet (SortedSet< E> s, Class< E> type)
  Returns a dynamically typesafe view of the specified sorted set.
publicstatic void copy (List<Object> dest, List<Object> src)
  Copies all of the elements from one list into another.
publicstatic boolean disjoint (Collection<Object> c1, Collection<Object> c2)
  Returns true if the two specified collections have no elements in common.
publicfinalstatic List< T> emptyList ()
  Returns the empty list (immutable).
publicfinalstatic Map< K, V> emptyMap ()
  Returns the empty map (immutable).
publicfinalstatic Set< T> emptySet ()
  Returns the empty set (immutable).
publicstatic Enumeration< T> enumeration (Collection< T> c)
  Returns an enumeration over the specified collection.
publicstatic void fill (List<Object> list, T obj)
  Replaces all of the elements of the specified list with the specified element.
publicstatic int frequency (Collection<Object> c, Object o)
  Returns the number of elements in the specified collection equal to the specified object.
publicstatic int indexOfSubList (List<Object> source, List<Object> target)
  Returns the starting position of the first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.
publicstatic int lastIndexOfSubList (List<Object> source, List<Object> target)
  Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.
publicstatic ArrayList< T> list (Enumeration< T> e)
  Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration.
publicstatic T max (Collection<Object> coll)
  Returns the maximum element of the given collection, according to the natural ordering of its elements.
publicstatic T max (Collection<Object> coll, Comparator<Object> comp)
  Returns the maximum element of the given collection, according to the order induced by the specified comparator.
publicstatic T min (Collection<Object> coll)
  Returns the minimum element of the given collection, according to the natural ordering of its elements.
publicstatic T min (Collection<Object> coll, Comparator<Object> comp)
  Returns the minimum element of the given collection, according to the order induced by the specified comparator.
publicstatic List< T> nCopies (int n, T o)
  Returns an immutable list consisting of n copies of the specified object.
publicstatic Set< E> newSetFromMap (Map< E, Boolean> map)
  Returns a set backed by the specified map.
publicstatic boolean replaceAll (List< T> list, T oldVal, T newVal)
  Replaces all occurrences of one specified value in a list with another.
publicstatic void reverse (List<Object> list)
  Reverses the order of the elements in the specified list.
publicstatic Comparator< T> reverseOrder ()
  Returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface.
publicstatic Comparator< T> reverseOrder (Comparator< T> cmp)
  Returns a comparator that imposes the reverse ordering of the specified comparator.
publicstatic void rotate (List<Object> list, int distance)
  Rotates the elements in the specified list by the specified distance.
publicstatic void shuffle (List<Object> list)
  Randomly permutes the specified list using a default source of randomness.
publicstatic void shuffle (List<Object> list, Random rnd)
  Randomly permute the specified list using the specified source of randomness.
publicstatic Set< T> singleton ( T o)
  Returns an immutable set containing only the specified object.
publicstatic List< T> singletonList ( T o)
  Returns an immutable list containing only the specified object.
publicstatic Map< K, V> singletonMap ( K key, V value)
  Returns an immutable map, mapping only the specified key to the specified value.
publicstatic void sort (List< T> list)
  Sorts the specified list into ascending order, according to the natural ordering of its elements.
publicstatic void sort (List< T> list, Comparator<Object> c)
  Sorts the specified list according to the order induced by the specified comparator.
publicstatic void swap (List<Object> list, int i, int j)
  Swaps the elements at the specified positions in the specified list.
publicstatic Collection< T> synchronizedCollection (Collection< T> c)
  Returns a synchronized (thread-safe) collection backed by the specified collection.
pack-privatestatic Collection< T> synchronizedCollection (Collection< T> c, Object mutex)
publicstatic List< T> synchronizedList (List< T> list)
  Returns a synchronized (thread-safe) list backed by the specified list.
pack-privatestatic List< T> synchronizedList (List< T> list, Object mutex)
publicstatic Map< K, V> synchronizedMap (Map< K, V> m)
  Returns a synchronized (thread-safe) map backed by the specified map.
publicstatic Set< T> synchronizedSet (Set< T> s)
  Returns a synchronized (thread-safe) set backed by the specified set.
pack-privatestatic Set< T> synchronizedSet (Set< T> s, Object mutex)
publicstatic SortedMap< K, V> synchronizedSortedMap (SortedMap< K, V> m)
  Returns a synchronized (thread-safe) sorted map backed by the specified sorted map.
publicstatic SortedSet< T> synchronizedSortedSet (SortedSet< T> s)
  Returns a synchronized (thread-safe) sorted set backed by the specified sorted set.
publicstatic Collection< T> unmodifiableCollection (Collection<Object> c)
  Returns an unmodifiable view of the specified collection.
publicstatic List< T> unmodifiableList (List<Object> list)
  Returns an unmodifiable view of the specified list.
publicstatic Map< K, V> unmodifiableMap (Map<Object, Object> m)
  Returns an unmodifiable view of the specified map.
publicstatic Set< T> unmodifiableSet (Set<Object> s)
  Returns an unmodifiable view of the specified set.
publicstatic SortedMap< K, V> unmodifiableSortedMap (SortedMap< K, Object> m)
  Returns an unmodifiable view of the specified sorted map.
publicstatic SortedSet< T> unmodifiableSortedSet (SortedSet< T> s)
  Returns an unmodifiable view of the specified sorted set.
Fields
Hide/Show inherited fields
publicfinalstatic List EMPTY_LIST
  The empty list (immutable).
publicfinalstatic Map EMPTY_MAP
  The empty map (immutable).
publicfinalstatic Set EMPTY_SET
  The empty set (immutable).
Nested Classes
  Collections.UnmodifiableCollection
  Collections.UnmodifiableSet
  Collections.UnmodifiableSortedSet
  Collections.UnmodifiableList
  Collections.UnmodifiableRandomAccessList
  Collections.UnmodifiableSortedMap
  Collections.SynchronizedCollection
  Collections.SynchronizedSet
  Collections.SynchronizedSortedSet
  Collections.SynchronizedList
  Collections.SynchronizedRandomAccessList
  Collections.SynchronizedSortedMap
  Collections.CheckedCollection
  Collections.CheckedSet
  Collections.CheckedSortedSet
  Collections.CheckedList
  Collections.CheckedRandomAccessList
  Collections.CheckedSortedMap
  Collections.AsLIFOQueue
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar