476 Part II: The Java Library
Method Description
static <T> boolean
addAll(Collection <? super T>c,
T ...elements)
Inser ts the elements specified byelementsinto the
collection specified byc.Returnstrueif the
elements were added andfalseother wise.
static <T> Queue<T> asLifoQueue(Deque<T>c) Returns a last-in, first-out view ofc. (Added by Java
SE 6.)
static <T>
int binar ySearch(List<? extends T>list,
Tvalue,
Comparator<? super T>c)
Searches forvalueinlistordered according toc.
Returns the position ofvalueinlist,or a negative
value ifvalueis not found.
static <T>
int binar ySearch(List<? extends
Comparable<? super T>>list,
Tvalue)
Searches forvalueinlist.The list must be sor ted.
Returns the position ofvalueinlist,or a negative
value ifvalueis not found.
static <E> Collection<E>
checkedCollection(Collection<E>c,
Class<E>t)
Returns a run-time type-safe view of a collection.
An attempt to inser t an incompatible element will
cause aClassCastException.
static <E> List<E>
checkedList(List<E>c, Class<E>t)
Returns a run-time type-safe view of aList. An
attempt to inser t an incompatible element will
cause aClassCastException.
static <K, V> Map<K, V>
checkedMap(Map<K, V>c,
Class<K>keyT,
Class<V>valueT)
Returns a run-time type-safe view of aMap. An
attempt to inser t an incompatible element will
cause aClassCastException.
static <E> List<E>
checkedSet(Set<E>c, Class<E>t)
Returns a run-time type-safe view of aSet. An
attempt to inser t an incompatible element will
cause aClassCastException.
static <K, V> Sor tedMap<K, V>
checkedSor tedMap(Sor tedMap<K, V>c,
Class<K>keyT,
Class<V>valueT)
Returns a run-time type-safe view of aSortedMap.
An attempt to inser t an incompatible element will
cause aClassCastException.
static <E> Sor tedSet<E>
checkedSor tedSet(Sor tedSet<E>c, Class<E>t)
Returns a run-time type-safe view of aSortedSet.
An attempt to inser t an incompatible element will
cause aClassCastException.
static <T> void copy(List<? super T>list1,
List<? extends T>list2)
Copies the elements oflist2tolist1.
static boolean disjoint(Collection<?>a,
Collection<?>b)
Compares the elements inato elements inb.
Returnstrueif the two collections contain no
common elements (i.e., the collections contain
disjoint sets of elements). Other wise, returnstrue.
static <T> List<T> emptyList( ) Returns an immutable, emptyListobject of the
inferred type.
static <K, V> Map<K, V> emptyMap( ) Returns an immutable, emptyMapobject of the
inferred type.
static <T> Set<T> emptySet( ) Returns an immutable, emptySetobject of the
inferred type.
static <T> Enumeration<T>
enumeration(Collection<T>c)
Returns an enumeration overc.(See βThe
Enumeration Inter face,β later in this chapter.)
static <T> void fill(List<? super T>list, Tobj) Assignsobjto each element oflist.
TABLE 17-14 The Algorithms Defined byCollections