org.graffiti.util
Class WeakHashSet<E>

java.lang.Object
  extended by org.graffiti.util.WeakHashSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class WeakHashSet<E>
extends Object
implements Set<E>

A Set implementation with weak elements. An element in a WeakHashSet will automatically be removed when it is no longer in ordinary use. The set is backed by a WeakHashMap , so all warnings on using WeakHashMap apply to WeakHashSet as well.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner
See Also:
WeakHashSet

Constructor Summary
WeakHashSet()
          Constructs a new, empty set; the backing WeakHashMap instance has default initial capacity (16) and load factor (0.75).
WeakHashSet(Collection<E> c)
          Constructs a new set containing the elements in the specified collection.
WeakHashSet(int initialCapacity)
          Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and default load factor, which is 0.75.
WeakHashSet(int initialCapacity, float loadFactor)
          Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and the specified load factor.
 
Method Summary
 boolean add(E e)
          
 boolean addAll(Collection<? extends E> c)
          
 void clear()
          
 boolean contains(Object o)
          
 boolean containsAll(Collection<?> c)
          
 boolean isEmpty()
          
 Iterator<E> iterator()
          
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> c)
          
 boolean retainAll(Collection<?> c)
          
 int size()
          
 Object[] toArray()
          
<T> T[]
toArray(T[] a)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

WeakHashSet

public WeakHashSet()
Constructs a new, empty set; the backing WeakHashMap instance has default initial capacity (16) and load factor (0.75).


WeakHashSet

public WeakHashSet(Collection<E> c)
Constructs a new set containing the elements in the specified collection.

Parameters:
c - the collection whose elements are to be placed into this set.
Throws:
NullPointerException - if the specified collection is null.

WeakHashSet

public WeakHashSet(int initialCapacity)
Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and default load factor, which is 0.75.

Parameters:
initialCapacity - the initial capacity of the hash table.

WeakHashSet

public WeakHashSet(int initialCapacity,
                   float loadFactor)
Constructs a new, empty set; the backing WeakHashMap instance has the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial capacity of the hash map.
loadFactor - the load factor of the hash map.
Throws:
IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
Method Detail

add

public boolean add(E e)

Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>

addAll

public boolean addAll(Collection<? extends E> c)

Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>

clear

public void clear()

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>

contains

public boolean contains(Object o)

Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>

containsAll

public boolean containsAll(Collection<?> c)

Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface Set<E>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>

iterator

public Iterator<E> iterator()

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>

remove

public boolean remove(Object o)

Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>

removeAll

public boolean removeAll(Collection<?> c)

Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface Set<E>

retainAll

public boolean retainAll(Collection<?> c)

Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface Set<E>

size

public int size()

Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>

toArray

public Object[] toArray()

Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>

toArray

public <T> T[] toArray(T[] a)

Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>


Generated at 2012-05-30 11:00:14 PM CEST