lapisx.util
Class SafeIteratorSet

java.lang.Object
  extended bylapisx.util.SafeIteratorSet
All Implemented Interfaces:
Collection, Set

public class SafeIteratorSet
extends Object
implements Set

This class implements the Set interface backed by a hash table. Iterators returned by a SafeIteratorSet iterate over an unmodifiable snapshot of the set, so it's safe to call add and remove on the original set even while iterators are running. Useful for storing a collection of event listeners.


Field Summary
static Debug debug
           
 
Constructor Summary
SafeIteratorSet()
          Make an empty SafeIteratorSet.
SafeIteratorSet(Collection c)
          Make a SafeIteratorSet initialized with the elements of a collection.
SafeIteratorSet(int initialCapacity)
          Make a SafeIteratorSet with an initial capacity.
SafeIteratorSet(int initialCapacity, float loadFactor)
          Make a SafeIteratorSet with an initial capacity and load factor.
 
Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 boolean equals(Object o)
           
 int hashCode()
           
 boolean isEmpty()
           
 Iterator iterator()
          Return an iterator over the elements in this set.
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static Debug debug
Constructor Detail

SafeIteratorSet

public SafeIteratorSet()
Make an empty SafeIteratorSet.


SafeIteratorSet

public SafeIteratorSet(Collection c)
Make a SafeIteratorSet initialized with the elements of a collection.

Parameters:
c - Initial members of the set

SafeIteratorSet

public SafeIteratorSet(int initialCapacity)
Make a SafeIteratorSet with an initial capacity.

Parameters:
initialCapacity - Initial capacity allocated to hash table

SafeIteratorSet

public SafeIteratorSet(int initialCapacity,
                       float loadFactor)
Make a SafeIteratorSet with an initial capacity and load factor.

Parameters:
initialCapacity - Initial capacity allocated to hash table
loadFactor - Load factor for hash table.
Method Detail

add

public boolean add(Object o)
Specified by:
add in interface Set

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Set

clear

public void clear()
Specified by:
clear in interface Set

contains

public boolean contains(Object o)
Specified by:
contains in interface Set

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Set

equals

public boolean equals(Object o)
Specified by:
equals in interface Set

hashCode

public int hashCode()
Specified by:
hashCode in interface Set

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Set

iterator

public Iterator iterator()
Return an iterator over the elements in this set. The iterator operates over an unmodifiable snapshot of this set's elements, so the set may be mutated without harm while the iterator is operating.

Specified by:
iterator in interface Set
Returns:
iterator over unmodifiable snapshot of this set

remove

public boolean remove(Object o)
Specified by:
remove in interface Set

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Set

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Set

size

public int size()
Specified by:
size in interface Set

toArray

public Object[] toArray()
Specified by:
toArray in interface Set

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Set