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:
Iterable<T>, Collection<T>, Set<T>

public class WeakHashSet<T>
extends AbstractSet<T>

HashSet backed by a WeakHashMap.


Constructor Summary
WeakHashSet()
          Get an instance of WeakHashSet.
WeakHashSet(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(Object o)
          True if this Set contains the given Object.
 boolean isEmpty()
          True if this set contains no elements.
 Iterator<T> 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<T> c)
Get a WeakHashSet with the contents from the given Collection.

Parameters:
c - the collection
Method Detail

iterator

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

Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface Set<T>
Specified by:
iterator in class AbstractCollection<T>

size

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

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

isEmpty

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

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

contains

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

Specified by:
contains in interface Collection<T>
Specified by:
contains in interface Set<T>
Overrides:
contains in class 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 Collection<T>
Specified by:
add in interface Set<T>
Overrides:
add in class 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(Object o)
Remove the given object from this Set.

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


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