| java.lang.Object | |
| ↳ | java.util.Collections |
Collections contains static methods which operate on Collection classes.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| List | EMPTY_LIST | ||||||||||
| Map | EMPTY_MAP | ||||||||||
| Set | EMPTY_SET | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Adds all the specified elements to the specified collection
| |||||||||||
Performs a binary search for the specified element in the specified
sorted List.
| |||||||||||
Performs a binary search for the specified element in the specified
sorted List using the specified Comparator.
| |||||||||||
Returns a dynamically typesafe view of the specified collection.
| |||||||||||
Returns a dynamically typesafe view of the specified list.
| |||||||||||
Returns a dynamically typesafe view of the specified map.
| |||||||||||
Returns a dynamically typesafe view of the specified set.
| |||||||||||
Returns a dynamically typesafe view of the specified sorted map.
| |||||||||||
Returns a dynamically typesafe view of the specified sorted set.
| |||||||||||
Copies the elements from the source list to the destination list.
| |||||||||||
Returns true if the collections have no elements in common
| |||||||||||
Returns a type-safe empty, immutable List.
| |||||||||||
Returns a type-safe empty, immutable Map.
| |||||||||||
Returns a type-safe empty, immutable Set.
| |||||||||||
Returns an Enumeration on the specified Collection.
| |||||||||||
Fills the specified List with the specified element.
| |||||||||||
Returns the number of elements in the | |||||||||||
Searches the
list for sublist and returns
the beginning index of the first occurrence. | |||||||||||
Searches the
list for sublist and returns
the beginning index of the last occurrence. | |||||||||||
Returns an ArrayList with all the elements in the
enumeration. | |||||||||||
Searches the specified Collection for the maximum element.
| |||||||||||
Searches the specified Collection for the maximum element using the
specified Comparator.
| |||||||||||
Searches the specified Collection for the minimum element.
| |||||||||||
Searches the specified Collection for the minimum element using the
specified Comparator.
| |||||||||||
Returns a List containing the specified number of the specified element.
| |||||||||||
Replaces all occurrences of Object
obj in
list with newObj. | |||||||||||
Returns the supplied
List with the order of its contained
elements reversed. | |||||||||||
Returns a Comparator that reverses the order of the
| |||||||||||
A Comparator which reverses the natural order of the elements. | |||||||||||
Rotates the elements in List
list by the distance
dist
e.g. | |||||||||||
Moves every element of the List to a random new position in the list.
| |||||||||||
Moves every element of the List to a random new position in the list
using the specified random number generator.
| |||||||||||
Returns a Set containing the specified element.
| |||||||||||
Returns a List containing the specified element.
| |||||||||||
Returns a Map containing the specified key and value.
| |||||||||||
Sorts the specified List using the specified Comparator.
| |||||||||||
Sorts the specified List in ascending order.
| |||||||||||
Swaps the elements of List
list at indices
index1 and index2 | |||||||||||
Returns a wrapper on the specified Collection which synchronizes all
access to the Collection.
| |||||||||||
Returns a wrapper on the specified List which synchronizes all access to
the List.
| |||||||||||
Returns a wrapper on the specified Map which synchronizes all access to
the Map.
| |||||||||||
Returns a wrapper on the specified Set which synchronizes all access to
the Set.
| |||||||||||
Returns a wrapper on the specified SortedMap which synchronizes all
access to the SortedMap.
| |||||||||||
Returns a wrapper on the specified SortedSet which synchronizes all
access to the SortedSet.
| |||||||||||
Returns a wrapper on the specified Collection which throws an
UnsupportedOperationException whenever an attempt is made
to modify the Collection. | |||||||||||
Returns a wrapper on the specified List which throws an
UnsupportedOperationException whenever an attempt is made
to modify the List. | |||||||||||
Returns a wrapper on the specified Map which throws an
UnsupportedOperationException whenever an attempt is made
to modify the Map. | |||||||||||
Returns a wrapper on the specified Set which throws an
UnsupportedOperationException whenever an attempt is made
to modify the Set. | |||||||||||
Returns a wrapper on the specified SortedMap which throws an
UnsupportedOperationException whenever an attempt is made
to modify the SortedMap. | |||||||||||
Returns a wrapper on the specified SortedSet which throws an
UnsupportedOperationException whenever an attempt is made
to modify the SortedSet. | |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
Adds all the specified elements to the specified collection
| c | the collection the elements are to be inserted into |
|---|---|
| a | the elements to insert |
| UnsupportedOperationException | when the method is not supported |
|---|---|
| NullPointerException | when c or elements is null, or elements contains one or more null elements and c doesn't support null elements |
Performs a binary search for the specified element in the specified sorted List.
| list | the sorted List to search |
|---|---|
| object | the element to find |
| ClassCastException | when an element in the List or the search element does not implement Comparable, or cannot be compared to each other |
|---|
Performs a binary search for the specified element in the specified sorted List using the specified Comparator.
| list | the sorted List to search |
|---|---|
| object | the element to find |
| comparator | the Comparator. If the comparator is null then
the search uses the objects' natural ordering. |
| ClassCastException | when an element in the list and the searched element cannot be compared to each other using the Comparator |
|---|
Returns a dynamically typesafe view of the specified collection.
| c | the collection |
|---|---|
| type | the type of the elements permitted to insert |
Returns a dynamically typesafe view of the specified list.
| list | the list |
|---|---|
| type | the type of the elements permitted to insert |
Returns a dynamically typesafe view of the specified map.
| m | the map |
|---|---|
| keyType | the type of the keys permitted to insert |
| valueType | the type of the values permitted to insert |
Returns a dynamically typesafe view of the specified set.
| s | the set |
|---|---|
| type | the type of the elements permitted to insert |
Returns a dynamically typesafe view of the specified sorted map.
| m | the sorted map |
|---|---|
| keyType | the type of the keys permitted to insert |
| valueType | the type of the values permitted to insert |
Returns a dynamically typesafe view of the specified sorted set.
| s | the sorted set |
|---|---|
| type | the type of the elements permitted to insert |
Copies the elements from the source list to the destination list.
| IndexOutOfBoundsException | when the destination List is smaller than the source List |
|---|---|
| UnsupportedOperationException | when replacing an element in the destination list is not supported |
Returns true if the collections have no elements in common
| c1 | the first collection |
|---|---|
| c2 | the second collection |
| NullPointerException | if one of the collections is null |
|---|
Returns an Enumeration on the specified Collection.
| collection | the Collection to enumerate |
|---|
Fills the specified List with the specified element.
| list | the List to fill |
|---|---|
| object | the fill element |
| UnsupportedOperationException | when replacing an element in the List is not supported |
|---|
Returns the number of elements in the Collection that
match the Object passed. If the Object is
null, then the number of null elements is
returned.
| c | The Collection to search. |
|---|---|
| o | The Object to search for. |
| NullPointerException | if the Collection parameter is
null. |
|---|
Searches the list for sublist and returns
the beginning index of the first occurrence.
-1 is returned if the sublist does not exist in
list
| list | the List to search sublist in |
|---|---|
| sublist | the List to search in list |
sublist in list, or -1
Searches the list for sublist and returns
the beginning index of the last occurrence.
-1 is returned if the sublist does not exist in
list
| list | the List to search sublist in |
|---|---|
| sublist | the List to search in list |
sublist in list, or -1
Returns an ArrayList with all the elements in the
enumeration. The elements in the returned ArrayList are
in the same order as in the enumeration.
| enumeration | Enumeration |
|---|
Searches the specified Collection for the maximum element.
| collection | the Collection to search |
|---|
| ClassCastException | when an element in the Collection does not implement Comparable or elements cannot be compared to each other |
|---|
Searches the specified Collection for the maximum element using the specified Comparator.
| collection | the Collection to search |
|---|---|
| comparator | the Comparator |
| ClassCastException | when elements in the Collection cannot be compared to each other using the Comparator |
|---|
Searches the specified Collection for the minimum element.
| collection | the Collection to search |
|---|
| ClassCastException | when an element in the Collection does not implement Comparable or elements cannot be compared to each other |
|---|
Searches the specified Collection for the minimum element using the specified Comparator.
| collection | the Collection to search |
|---|---|
| comparator | the Comparator |
| ClassCastException | when elements in the Collection cannot be compared to each other using the Comparator |
|---|
Returns a List containing the specified number of the specified element. The list cannot be modified.
| length | the size of the returned List |
|---|---|
| object | the element |
length copies of the element| IllegalArgumentException | when length < 0
|
|---|
Replaces all occurrences of Object obj in
list with newObj. If the obj
is null, then all occurrences of null is
replaced with newObj.
| list | the List to modify |
|---|---|
| obj | the Object to find and replace occurrences of. |
| obj2 | the Object to replace all occurrences of obj in
list |
obj has been
found in list| UnsupportedOperationException | if the list does not support setting elements |
|---|
Returns the supplied List with the order of its contained
elements reversed.
| list | the List to reverse |
|---|
| UnsupportedOperationException | when replacing an element in the List is not supported |
|---|
Returns a Comparator that reverses the order of the
Comparator passed. If the Comparator passed
is null, then this method is equivalent to
reverseOrder().
The Comparator that's returned is Serializable if
the Comparator passed is serializable or null.
| c | The Comparator to reverse or null. |
|---|
Comparator instance.
A Comparator which reverses the natural order of the elements. The
Comparator that's returned is Serializable.
Comparator instance.Rotates the elements in List list by the distance
dist
e.g. for a given list with elements [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], calling rotate(list, 3) or rotate(list, -7) would modify the list to look like this: [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]
| dist | It can be any integer: 0, positive, negative, larger than the list size |
|---|
Moves every element of the List to a random new position in the list.
| list | the List to shuffle |
|---|
| UnsupportedOperationException | when replacing an element in the List is not supported |
|---|
Moves every element of the List to a random new position in the list using the specified random number generator.
| list | the List to shuffle |
|---|---|
| random | the random number generator |
| UnsupportedOperationException | when replacing an element in the List is not supported |
|---|
Returns a Set containing the specified element. The set cannot be modified.
| object | the element |
|---|
Returns a List containing the specified element. The list cannot be modified.
| object | the element |
|---|
Returns a Map containing the specified key and value. The map cannot be modified.
| key | the key |
|---|---|
| value | the value |
Sorts the specified List using the specified Comparator.
| list | the List to be sorted |
|---|---|
| comparator | the Comparator |
| ClassCastException | when elements in the List cannot be compared to each other using the Comparator |
|---|
Sorts the specified List in ascending order.
| list | the List to be sorted |
|---|
| ClassCastException | when an element in the List does not implement Comparable or elements cannot be compared to each other |
|---|
Swaps the elements of List list at indices
index1 and index2
| list | the List to manipulate on |
|---|---|
| index1 | int position of the first element to swap with the element in index2 |
| index2 | int position of the other element |
| IndexOutOfBoundsException | if index1 or index2 is out of range of this list |
|---|
Returns a wrapper on the specified Collection which synchronizes all access to the Collection.
| collection | the Collection |
|---|
Returns a wrapper on the specified List which synchronizes all access to the List.
| list | the List |
|---|
Returns a wrapper on the specified Map which synchronizes all access to the Map.
| map | the Map |
|---|
Returns a wrapper on the specified Set which synchronizes all access to the Set.
| set | the Set |
|---|
Returns a wrapper on the specified SortedMap which synchronizes all access to the SortedMap.
| map | the SortedMap |
|---|
Returns a wrapper on the specified SortedSet which synchronizes all access to the SortedSet.
| set | the SortedSet |
|---|
Returns a wrapper on the specified Collection which throws an
UnsupportedOperationException whenever an attempt is made
to modify the Collection.
| collection | the Collection |
|---|
Returns a wrapper on the specified List which throws an
UnsupportedOperationException whenever an attempt is made
to modify the List.
| list | the List |
|---|
Returns a wrapper on the specified Map which throws an
UnsupportedOperationException whenever an attempt is made
to modify the Map.
| map | the Map |
|---|
Returns a wrapper on the specified Set which throws an
UnsupportedOperationException whenever an attempt is made
to modify the Set.
| set | the Set |
|---|
Returns a wrapper on the specified SortedMap which throws an
UnsupportedOperationException whenever an attempt is made
to modify the SortedMap.
| map | the SortedMap |
|---|
Returns a wrapper on the specified SortedSet which throws an
UnsupportedOperationException whenever an attempt is made
to modify the SortedSet.
| set | the SortedSet |
|---|