java.util
Class WeakHashMap.Values

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.WeakHashMap.Values
All Implemented Interfaces:
Collection
Enclosing class:
WeakHashMap

private class WeakHashMap.Values
extends AbstractCollection


Constructor Summary
private WeakHashMap.Values()
           
 
Method Summary
 void clear()
          Removes all of the elements from this collection (optional operation).
 boolean contains(Object o)
          Returns true if this collection contains the specified element.
 Iterator iterator()
          Returns an iterator over the elements contained in this collection.
 int size()
          Returns the number of elements in this collection.
 Object[] toArray()
          Returns an array containing all of the elements in this collection.
 Object[] toArray(Object[] a)
          Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 
Methods inherited from class java.util.AbstractCollection
add, addAll, containsAll, isEmpty, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

WeakHashMap.Values

private WeakHashMap.Values()
Method Detail

iterator

public Iterator iterator()
Description copied from class: AbstractCollection
Returns an iterator over the elements contained in this collection.

Specified by:
iterator in interface Collection
Specified by:
iterator in class AbstractCollection
Returns:
an iterator over the elements contained in this collection.

size

public int size()
Description copied from class: AbstractCollection
Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface Collection
Specified by:
size in class AbstractCollection
Returns:
the number of elements in this collection.

contains

public boolean contains(Object o)
Description copied from class: AbstractCollection
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)).

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.

Specified by:
contains in interface Collection
Overrides:
contains in class AbstractCollection
Parameters:
o - object to be checked for containment in this collection.
Returns:
true if this collection contains the specified element.

clear

public void clear()
Description copied from class: AbstractCollection
Removes all of the elements from this collection (optional operation). The collection will be empty after this call returns (unless it throws an exception).

This implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.

Specified by:
clear in interface Collection
Overrides:
clear in class AbstractCollection

toArray

public Object[] toArray()
Description copied from class: AbstractCollection
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 implementation allocates the array to be returned, and iterates over the elements in the collection, storing each object reference in the next consecutive element of the array, starting with element 0.

Specified by:
toArray in interface Collection
Overrides:
toArray in class AbstractCollection
Returns:
an array containing all of the elements in this collection.

toArray

public Object[] toArray(Object[] a)
Description copied from class: AbstractCollection
Returns an array containing all of the elements in this collection; the runtime type of the returned array 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.

This implementation checks if the array is large enough to contain the collection; if not, it allocates a new array of the correct size and type (using reflection). Then, it iterates over the collection, storing each object reference in the next consecutive element of the array, starting with element 0. If the array is larger than the collection, a null is stored in the first location after the end of the collection.

Specified by:
toArray in interface Collection
Overrides:
toArray in class AbstractCollection
Parameters:
a - the array into which the elements of the collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of the collection.