img
Method
Description
static int frequency(Collection<?> c, Object obj)
Counts the number of occurrences of obj in c and
returns the result.
static int indexOfSubList(List<?> list,
Searches list for the first occurrence of subList.
List<?> subList)
Returns the index of the first match, or ­1 if no
match is found.
static int lastIndexOfSubList(List<?> list,
Searches list for the last occurrence of subList.
List<?> subList)
Returns the index of the last match, or ­1 if no
match is found.
Returns an ArrayList that contains the elements
static <T>
ArrayList<T> list(Enumeration<T> enum)
of enum.
static <T> T max(Collection<? extends T> c,
Returns the maximum element in c as determined
Comparator<? super T> comp)
by comp.
Returns the maximum element in c as determined
static <T extends Object &
Comparable<? super T>>
by natural ordering. The collection need not be
T max(Collection<? extends T> c)
sor ted.
static <T> T min(Collection<? extends T> c,
Returns the minimum element in c as determined
Comparator<? super T> comp)
by comp. The collection need not be sor ted.
Returns the minimum element in c as determined
static <T extends Object &
by natural ordering.
Comparable<? superT>>
T min(Collection<? extends T> c)
static <T> List<T> nCopies(int num, T obj)
Returns num copies of obj contained in an immutable
list. num must be greater than or equal to zero.
static <E> Set<E> newSetFromMap(Map<E, Boolean> m) Creates and returns a set backed by the map
specified by m, which must be empty at the time
this method is called. (Added by Java SE 6.)
static <T> boolean replaceAll(List<T> list,
Replaces all occurrences of old with new in list.
T old, T new)
Returns true if at least one replacement occurred.
Returns false, other wise.
static void reverse(List<T> list)
Reverses the sequence in list.
static <T> Comparator<T>
Returns a reverse comparator based on the one
reverseOrder(Comparator<T> comp)
passed in comp. That is, the returned comparator
reverses the outcome of a comparison that uses
comp.
static <T> Comparator<T> reverseOrder( )
Returns a reverse comparator, which is a
comparator that reverses the outcome of a
comparison between two elements.
static void rotate(List<T> list, int n)
Rotates list by n places to the right. To rotate left,
use a negative value for n.
static void shuf fle(List<T> list, Random r)
Shuf fles (i.e., randomizes) the elements in list by
using r as a source of random numbers.
static void shuf fle(List<T> list)
Shuf fles (i.e., randomizes) the elements in list.
static <T> Set<T> singleton(T obj)
Returns obj as an immutable set. This is an easy
way to conver t a single object into a set.
static <T> List<T> singletonList(T obj)
Returns obj as an immutable list. This is an easy
way to conver t a single object into a list.
Returns the key/value pair k/v as an immutable
static <K, V> Map<K, V>
singletonMap(K k, V v)
map. This is an easy way to conver t a single key/
value pair into a map.
TABLE 17-14
The Algorithms Defined by Collections (continued)
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home