net.spy.util
Class WeakHashSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended bynet.spy.util.WeakHashSet
All Implemented Interfaces:
Collection, Set

public class WeakHashSet
extends AbstractSet

HashSet backed by a WeakHashMap.


Constructor Summary
WeakHashSet()
          Get an instance of WeakHashSet.
WeakHashSet(Collection c)
          Get a WeakHashSet with the contents from the given Collection.
WeakHashSet(int n)
          Create a WeakHashSet with the given capacity.
 
Method Summary
 boolean add(Object o)
          Add this object to this Set if it's not already present.
 void clear()
          Remove all entries from this Set.
 boolean contains(Object o)
          True if this Set contains the given Object.
 boolean isEmpty()
          True if this set contains no elements.
 Iterator iterator()
          Get the Iterator for the backing Map.
 boolean remove(Object o)
          Remove the given object from this Set.
 int size()
          Get the number of keys currently contained in this Set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, toArray, toArray
 

Constructor Detail

WeakHashSet

public WeakHashSet()
Get an instance of WeakHashSet.


WeakHashSet

public WeakHashSet(int n)
Create a WeakHashSet with the given capacity.

Parameters:
n - the capacity

WeakHashSet

public WeakHashSet(Collection c)
Get a WeakHashSet with the contents from the given Collection.

Parameters:
c - the collection
Method Detail

iterator

public Iterator iterator()
Get the Iterator for the backing Map.


size

public int size()
Get the number of keys currently contained in this Set.


isEmpty

public boolean isEmpty()
True if this set contains no elements.


contains

public boolean contains(Object o)
True if this Set contains the given Object.


add

public boolean add(Object o)
Add this object to this Set if it's not already present.

Parameters:
o - the object to add
Returns:
true if this object was just added, false if it already existed

remove

public boolean remove(Object o)
Remove the given object from this Set.

Parameters:
o - Object to be removed
Returns:
true if the Set did contain this object (but now doesn't)

clear

public void clear()
Remove all entries from this Set.