net.spy.util
Class WeakHashSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by net.spy.util.WeakHashSet
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.Set

public class WeakHashSet
extends java.util.AbstractSet

HashSet backed by a WeakHashMap.


Constructor Summary
WeakHashSet()
          Get an instance of WeakHashSet.
WeakHashSet(java.util.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(java.lang.Object o)
          Add this object to this Set if it's not already present.
 void clear()
          Remove all entries from this Set.
 boolean contains(java.lang.Object o)
          True if this Set contains the given Object.
 boolean isEmpty()
          True if this set contains no elements.
 java.util.Iterator iterator()
          Get the Iterator for the backing Map.
 boolean remove(java.lang.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(java.util.Collection c)
Get a WeakHashSet with the contents from the given Collection.

Parameters:
c - the collection
Method Detail

iterator

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

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection

size

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

Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set
Specified by:
size in class java.util.AbstractCollection

isEmpty

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

Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.Set
Overrides:
isEmpty in class java.util.AbstractCollection

contains

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

Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set
Overrides:
contains in class java.util.AbstractCollection

add

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

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection
Parameters:
o - the object to add
Returns:
true if this object was just added, false if it already existed

remove

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

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.AbstractCollection
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.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.AbstractCollection


Copyright © 1995-2005 SPY Internetworking. All Rights Reserved.