Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class java.util.Collections.SynchronizedCollection

java.lang.Object
  |
  +--java.util.Collections.SynchronizedCollection
Subclasses:
Collections.SynchronizedList, Collections.SynchronizedSet

static class Collections.SynchronizedCollection
extends java.lang.Object
implements Collection, java.io.Serializable
See Also:
Serialized Form

Constructor Summary
Collections.SynchronizedCollection(Collection c)
           
Collections.SynchronizedCollection(Collection c, java.lang.Object mutex)
           
 
Method Summary
boolean addAll(Collection coll)
           
boolean add(java.lang.Object o)
           
void clear()
           
boolean containsAll(Collection coll)
           
boolean contains(java.lang.Object o)
           
boolean isEmpty()
           
Iterator iterator()
           
boolean removeAll(Collection coll)
           
boolean remove(java.lang.Object o)
           
boolean retainAll(Collection coll)
           
int size()
           
java.lang.Object[] toArray()
           
java.lang.Object[] toArray(java.lang.Object[] a)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

Collections.SynchronizedCollection

Collections.SynchronizedCollection(Collection c)

Collections.SynchronizedCollection

Collections.SynchronizedCollection(Collection c,
                                   java.lang.Object mutex)
Method Detail

size

public int size()
Description copied from interface:
Returns the number of elements in this Collection.
Specified by:
size in interface Collection


isEmpty

public boolean isEmpty()
Description copied from interface:
Returns true if this Collection contains no elements.
Specified by:
isEmpty in interface Collection


contains

public boolean contains(java.lang.Object o)
Description copied from interface:
Returns true if this Collection contains the specified element. More formally, returns true if and only if this Collection contains at least one element e such that (o==null ? e==null : o.equals(e)).
Specified by:
contains in interface Collection


toArray

public java.lang.Object[] toArray()
Description copied from interface:
Returns an array containing all of the elements in this Collection. If the Collection makes any guarantees as to what order its elements are returned by its Iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by the Collection. (In other words, this method must allocate a new array even if the Collection is backed by an Array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and Collection-based APIs.

Specified by:
toArray in interface Collection



toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Description copied from interface:
Returns an array containing all of the elements in this Collection, whose runtime type is that of the specified array. If the Collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this Collection.

If the Collection fits in the specified array with room to spare (i.e., the array has more elements than the Collection), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of the Collection only if the caller knows that the Collection does not contain any null elements.)

If this Collection makes any guarantees as to what order its elements are returned by its Iterator, this method must return the elements in the same order.

Like toArray(), this method acts as bridge between array-based and Collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs

Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

 String[] x = (String[]) v.toArray(new String[0]);
 

Note that toArray(new Object[0]) is identical in function to toArray().

Specified by:
toArray in interface Collection



iterator

public Iterator iterator()
Description copied from interface:
Returns an Iterator over the elements in this Collection. There are no guarantees concerning the order in which the elements are returned (unless this Collection is an instance of some class that provides a guarantee).
Specified by:
iterator in interface Collection


add

public boolean add(java.lang.Object o)
Description copied from interface:
Ensures that this Collection contains the specified element (optional operation). Returns true if the Collection changed as a result of the call. (Returns false if this Collection does not permit duplicates and already contains the specified element.) Collections that support this operation may place limitations on what elements may be added to the Collection. In particular, some Collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.
Specified by:
add in interface Collection


remove

public boolean remove(java.lang.Object o)
Description copied from interface:
Removes a single instance of the specified element from this Collection, if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if the Collection contains one or more such elements. Returns true if the Collection contained the specified element (or equivalently, if the Collection changed as a result of the call).
Specified by:
remove in interface Collection


containsAll

public boolean containsAll(Collection coll)
Description copied from interface:
Returns true if this Collection contains all of the elements in the specified Collection.
Specified by:
containsAll in interface Collection


addAll

public boolean addAll(Collection coll)
Description copied from interface:
Adds all of the elements in the specified Collection to this Collection (optional operation). The behavior of this operation is undefined if the specified Collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the the specified Collection is this Collection, and this Collection is nonempty.)
Specified by:
addAll in interface Collection


removeAll

public boolean removeAll(Collection coll)
Description copied from interface:
Removes from this Collection all of its elements that are contained in the specified Collection (optional operation). After this call returns, this Collection will contains no elements in common with the specified Collection.
Specified by:
removeAll in interface Collection


retainAll

public boolean retainAll(Collection coll)
Description copied from interface:
Retains only the elements in this Collection that are contained in the specified Collection (optional operation). In other words, removes from this Collection all of its elements that are not contained in the specified Collection.
Specified by:
retainAll in interface Collection


clear

public void clear()
Description copied from interface:
Removes all of the elements from this Collection (optional operation). The Collection will be empty after this call returns (unless it throws an exception).
Specified by:
clear in interface Collection


Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD