net.spy.util
Class WeakHashSet<T>

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

public class WeakHashSet<T>
extends java.util.AbstractSet<T>

HashSet backed by a WeakHashMap.


Constructor Summary
WeakHashSet()
          Get an instance of WeakHashSet.
WeakHashSet(java.util.Collection<T> 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(T 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<T> 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<T> c)
Get a WeakHashSet with the contents from the given Collection.

Parameters:
c - the collection
Method Detail

iterator

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

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

size

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

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

isEmpty

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

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

contains

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

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

add

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

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


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