The methods of this class all throw a NullPointerException
if the collections or class objects provided to them are null.
The documentation for the polymorphic algorithms contained in this class
generally includes a brief description of the implementation. Such
descriptions should be regarded as implementation notes, rather than
parts of the specification. Implementors should feel free to
substitute other algorithms, so long as the specification itself is adhered
to. (For example, the algorithm used by sort does not have to be
a mergesort, but it does have to be stable.)
The "destructive" algorithms contained in this class, that is, the
algorithms that modify the collection on which they operate, are specified
to throw UnsupportedOperationException if the collection does not
support the appropriate mutation primitive(s), such as the set
method. These algorithms may, but are not required to, throw this
exception if an invocation would have no effect on the collection. For
example, invoking the sort method on an unmodifiable list that is
already sorted may or may not throw UnsupportedOperationException.
This class is a member of the Java Collections Framework.
Collection, Set, List, Map
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| private static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| private static class | |
| pack-priv static class | |
| pack-priv static class | |
| private static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| private static class | |
| pack-priv static class | |
| pack-priv static class | Collections.
type of elements E>Wraps a navigable set and disables all of the mutative operations. |
| pack-priv static class | |
| pack-priv static class | |
| private static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final int | |
| public static final List | EMPTY_LIST
The empty list (immutable). |
| public static final Map | EMPTY_MAP
The empty map (immutable). |
| public static final Set | EMPTY_SET
The empty set (immutable). |
| private static final int | |
| private static final int | |
| private static Random | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static < the class of the elements to add and of the collection T> boolean | Returns: true if the collection changed as a result of the callthe collection into which c, T... elements are to be insertedthe elements to insert into elements)cAdds all of the specified elements to the specified collection. |
| public static < the class of the objects in the deque T> Queue | Returns: the queuethe deque deque)Returns a view of a |
| public static < the class of the objects in the list T> int | Returns: the index of the search key, if it is contained in the list; otherwise,(-(insertion point) - 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 list.size() 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.the list to be searched. list, T the key to be searched for. key)Searches the specified list for the specified object using the binary search algorithm. |
| public static < the class of the objects in the list T> int | Returns: the index of the search key, if it is contained in the list; otherwise,(-(insertion point) - 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 list.size() 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.the list to be searched. list, T the key to be searched for. key, Comparator<? super T> the comparator by which the list is ordered.
A c)null value indicates that the elements'
natural ordering should be used.Searches the specified list for the specified object using the binary search algorithm. |
| public static < the class of the objects in the collection E> Collection | Returns: a dynamically typesafe view of the specified collectionthe collection for which a dynamically typesafe view is to be
returned c, Class<E> the type of element that type)c is permitted to holdReturns a dynamically typesafe view of the specified collection. |
| public static < the class of the objects in the list E> List | Returns: a dynamically typesafe view of the specified listthe list for which a dynamically typesafe view is to be
returned list, Class<E> the type of element that type)list is permitted to holdReturns a dynamically typesafe view of the specified list. |
| public static < the class of the map keys K, the class of the map values V> Map | Returns: a dynamically typesafe view of the specified mapthe map for which a dynamically typesafe view is to be
returned m, Class<K> the type of key that keyType, Class<V> m is permitted to holdthe type of value that valueType)m is permitted to holdReturns a dynamically typesafe view of the specified map. |
| public static < type of map keys K, type of map values V> NavigableMap | Returns: a dynamically typesafe view of the specified mapthe map for which a dynamically typesafe view is to be
returned m, Class<K> the type of key that keyType, Class<V> m is permitted to holdthe type of value that valueType)m is permitted to holdReturns a dynamically typesafe view of the specified navigable map. |
| public static < the class of the objects in the set E> NavigableSet | Returns: a dynamically typesafe view of the specified navigable setthe navigable set for which a dynamically typesafe view is to be
returned s, Class<E> the type of element that type)s is permitted to holdReturns a dynamically typesafe view of the specified navigable set. |
| public static < the class of the objects in the queue E> Queue | Returns: a dynamically typesafe view of the specified queuethe queue for which a dynamically typesafe view is to be
returned queue, Class<E> the type of element that type)queue is permitted to holdReturns a dynamically typesafe view of the specified queue. |
| public static < the class of the objects in the set E> Set | Returns: a dynamically typesafe view of the specified setthe set for which a dynamically typesafe view is to be
returned s, Class<E> the type of element that type)s is permitted to holdReturns a dynamically typesafe view of the specified set. |
| public static < the class of the map keys K, the class of the map values V> SortedMap | Returns: a dynamically typesafe view of the specified mapthe map for which a dynamically typesafe view is to be
returned m, Class<K> the type of key that keyType, Class<V> m is permitted to holdthe type of value that valueType)m is permitted to holdReturns a dynamically typesafe view of the specified sorted map. |
| public static < the class of the objects in the set E> SortedSet | Returns: a dynamically typesafe view of the specified sorted setthe sorted set for which a dynamically typesafe view is to be
returned s, Class<E> the type of element that type)s is permitted to holdReturns a dynamically typesafe view of the specified sorted set. |
| public static < the class of the objects in the lists T> void | |
| public static boolean | Returns: true if the two specified collections have no
elements in common.a collection c1, Collection<?> a collection c2)Returns |
| public static < the class of the objects in the enumeration T> Enumeration | |
| public static < type of elements, if there were any, in the iterator T> Iterator | |
| public static final < type of elements, if there were any, in the list T> List | |
| public static < type of elements, if there were any, in the iterator T> ListIterator | |
| public static final < the class of the map keys K, the class of the map values V> Map | |
| public static final < the class of the map keys K, the class of the map values V> NavigableMap | |
| public static < type of elements, if there were any, in the set E> NavigableSet | |
| public static final < the class of the objects in the set T> Set | |
| public static final < the class of the map keys K, the class of the map values V> SortedMap | |
| public static < type of elements, if there were any, in the set E> SortedSet | |
| public static < the class of the objects in the collection T> Enumeration | Returns: an enumeration over the specified collection.the collection for which an enumeration is to be returned. c)Returns an enumeration over the specified collection. |
| pack-priv static boolean | |
| public static < the class of the objects in the list T> void | |
| public static int | Returns: the number of elements inc equal to othe collection in which to determine the frequency
of c, Object othe object whose frequency is to be determined o)Returns the number of elements in the specified collection equal to the specified object. |
| private static <T> T | get(ListIterator<? extends T> i, int index)
Gets the ith element from the given list by repositioning the specified list listIterator. |
| private static <T> int | |
| private static <T> int | |
| public static int | 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.the list in which to search for the first occurrence
of source, List<?> target.the list to search for as a subList of target)source.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. |
| private static <T> int | |
| private static <T> int | |
| public static int | 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.the list in which to search for the last occurrence
of source, List<?> target.the list to search for as a subList of target)source.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. |
| public static < the class of the objects returned by the enumeration T> ArrayList | Returns: an array list containing the elements returned by the specified enumeration.enumeration providing elements for the returned
array list e)Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration. |
| public static < the class of the objects in the collection T extends Comparable | Returns: the maximum element of the given collection, according to the natural ordering of its elements.the collection whose maximum element is to be determined. coll)Returns the maximum element of the given collection, according to the natural ordering of its elements. |
| public static < the class of the objects in the collection T> T | Returns: the maximum element of the given collection, according to the specified comparator.the collection whose maximum element is to be determined. coll, Comparator<? super T> the comparator with which to determine the maximum element.
A comp)null value indicates that the elements' natural
ordering should be used.Returns the maximum element of the given collection, according to the order induced by the specified comparator. |
| public static < the class of the objects in the collection T extends Comparable | Returns: the minimum element of the given collection, according to the natural ordering of its elements.the collection whose minimum element is to be determined. coll)Returns the minimum element of the given collection, according to the natural ordering of its elements. |
| public static < the class of the objects in the collection T> T | Returns: the minimum element of the given collection, according to the specified comparator.the collection whose minimum element is to be determined. coll, Comparator<? super T> the comparator with which to determine the minimum element.
A comp)null value indicates that the elements' natural
ordering should be used.Returns the minimum element of the given collection, according to the order induced by the specified comparator. |
| public static < the class of the object to copy and of the objects
in the returned list. T> List | Returns: an immutable list consisting ofn copies of the
specified object.the number of elements in the returned list. n, T the element to appear repeatedly in the returned list. o)Returns an immutable list consisting of |
| public static < the class of the map keys and of the objects in the
returned set E> SequencedSet | Returns: the set backed by the mapthe backing map map)Returns a sequenced set backed by the specified map. |
| public static < the class of the map keys and of the objects in the
returned set E> Set | Returns: the set backed by the mapthe backing map map)Returns a set backed by the specified map. |
| public static < the class of the objects in the list T> boolean | Returns: true if list contained one or more elements
e such that
(oldVal==null ? e==null : oldVal.equals(e)).the list in which replacement is to occur. list, T the old value to be replaced. oldVal, T the new value with which newVal)oldVal is to be
replaced.Replaces all occurrences of one specified value in a list with another. |
| public static void | |
| public static < the class of the objects compared by the comparator T> Comparator | Returns: A comparator that imposes the reverse of the natural ordering on a collection of objects that implement theComparable interface.Returns a comparator that imposes the reverse of the natural
ordering on a collection of objects that implement the
|
| public static < the class of the objects compared by the comparator T> Comparator | Returns: A comparator that imposes the reverse ordering of the specified comparator.a comparator who's ordering is to be reversed by the returned
comparator or cmp)nullReturns a comparator that imposes the reverse ordering of the specified comparator. |
| public static void | |
| private static <T> void | |
| private static void | |
| public static void | |
| public static void | |
| public static void | shuffle(List<?>
the list to be shuffled. list, RandomGenerator the source of randomness to use to shuffle the list. rnd)Randomly permute the specified list using the specified source of randomness. |
| public static < the class of the objects in the set T> Set | Returns: an immutable set containing only the specified object.the sole object to be stored in the returned set. o)Returns an immutable set containing only the specified object. |
| pack-priv static <E> Iterator | |
| public static < the class of the objects in the list T> List | Returns: an immutable list containing only the specified object.the sole object to be stored in the returned list. o)Returns an immutable list containing only the specified object. |
| public static < the class of the map keys K, the class of the map values V> Map | Returns: an immutable map containing only the specified key-value mapping.the sole key to be stored in the returned map. key, V the value to which the returned map maps value)key.Returns an immutable map, mapping only the specified key to the specified value. |
| pack-priv static < Type of elements T> Spliterator | Returns: A singletonSpliteratorCreates a |
| public static < the class of the objects in the list T extends Comparable | sort(List<T>
the list to be sorted. list)Sorts the specified list into ascending order, according to the natural ordering of its elements. |
| public static < the class of the objects in the list T> void | sort(List<T>
the list to be sorted. list, Comparator<? super T> the comparator to determine the order of the list. A
c)null value indicates that the elements' natural
ordering should be used.Sorts the specified list according to the order induced by the specified comparator. |
| public static void | |
| private static void | |
| public static < the class of the objects in the collection T> Collection | Returns: a synchronized view of the specified collection.the collection to be "wrapped" in a synchronized collection. c)Returns a synchronized (thread-safe) collection backed by the specified collection. |
| pack-priv static <T> Collection | |
| public static < the class of the objects in the list T> List | Returns: a synchronized view of the specified list.the list to be "wrapped" in a synchronized list. list)Returns a synchronized (thread-safe) list backed by the specified list. |
| pack-priv static <T> List | |
| public static < the class of the map keys K, the class of the map values V> Map | Returns: a synchronized view of the specified map.the map to be "wrapped" in a synchronized map. m)Returns a synchronized (thread-safe) map backed by the specified map. |
| public static < the class of the map keys K, the class of the map values V> NavigableMap | Returns: a synchronized view of the specified navigable map.the navigable map to be "wrapped" in a synchronized navigable
map m)Returns a synchronized (thread-safe) navigable map backed by the specified navigable map. |
| public static < the class of the objects in the set T> NavigableSet | Returns: a synchronized view of the specified navigable setthe navigable set to be "wrapped" in a synchronized navigable
set s)Returns a synchronized (thread-safe) navigable set backed by the specified navigable set. |
| public static < the class of the objects in the set T> Set | Returns: a synchronized view of the specified set.the set to be "wrapped" in a synchronized set. s)Returns a synchronized (thread-safe) set backed by the specified set. |
| pack-priv static <T> Set | |
| public static < the class of the map keys K, the class of the map values V> SortedMap | Returns: a synchronized view of the specified sorted map.the sorted map to be "wrapped" in a synchronized sorted map. m)Returns a synchronized (thread-safe) sorted map backed by the specified sorted map. |
| public static < the class of the objects in the set T> SortedSet | Returns: a synchronized view of the specified sorted set.the sorted set to be "wrapped" in a synchronized sorted set. s)Returns a synchronized (thread-safe) sorted set backed by the specified sorted set. |
| public static < the class of the objects in the collection T> Collection | Returns: an unmodifiable view of the specified collection.the collection for which an unmodifiable view is to be
returned. c)Returns an unmodifiable view of the specified collection. |
| public static < the class of the objects in the list T> List | Returns: an unmodifiable view of the specified list.the list for which an unmodifiable view is to be returned. list)Returns an unmodifiable view of the specified list. |
| public static < the class of the map keys K, the class of the map values V> Map | Returns: an unmodifiable view of the specified map.the map for which an unmodifiable view is to be returned. m)Returns an unmodifiable view of the specified map. |
| public static < the class of the map keys K, the class of the map values V> NavigableMap | Returns: an unmodifiable view of the specified navigable mapthe navigable map for which an unmodifiable view is to be
returned m)Returns an unmodifiable view of the specified navigable map. |
| public static < the class of the objects in the set T> NavigableSet | Returns: an unmodifiable view of the specified navigable setthe navigable set for which an unmodifiable view is to be
returned s)Returns an unmodifiable view of the specified navigable set. |
| public static < the class of the objects in the collection T> SequencedCollection | Returns: an unmodifiable view of the specified collection.the collection for which an unmodifiable view is to be
returned. c)Returns an unmodifiable view of the
specified |
| public static < the class of the map keys K, the class of the map values V> SequencedMap | Returns: an unmodifiable view of the specified map.the map for which an unmodifiable view is to be returned. m)Returns an unmodifiable view of the
specified |
| public static < the class of the objects in the set T> SequencedSet | Returns: an unmodifiable view of the specified sequenced set.the set for which an unmodifiable view is to be returned. s)Returns an unmodifiable view of the
specified |
| public static < the class of the objects in the set T> Set | Returns: an unmodifiable view of the specified set.the set for which an unmodifiable view is to be returned. s)Returns an unmodifiable view of the specified set. |
| public static < the class of the map keys K, the class of the map values V> SortedMap | Returns: an unmodifiable view of the specified sorted map.the sorted map for which an unmodifiable view is to be
returned. m)Returns an unmodifiable view of the specified sorted map. |
| public static < the class of the objects in the set T> SortedSet | Returns: an unmodifiable view of the specified sorted set.the sorted set for which an unmodifiable view is to be
returned. s)Returns an unmodifiable view of the specified sorted set. |
| pack-priv static <T> T[] |