pivot.collections
Class HashSet<E>

java.lang.Object
  extended by pivot.collections.HashSet<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Group<E>, Set<E>

public class HashSet<E>
extends Object
implements Set<E>, Serializable

Implementation of the Set interface that is backed by a hashtable.

TODO We're temporarily using a java.util.HashSet to back this set. Eventually, we'll replace this with an internal set representation.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface pivot.collections.Set
Set.SetListenerList<E>
 
Field Summary
protected  HashSet<E> hashSet
           
 
Constructor Summary
HashSet()
           
HashSet(Comparator<E> comparator)
           
HashSet(Set<E> set)
           
 
Method Summary
 void add(E element)
          Adds an element to the group.
 void clear()
          Removes all elements from the collection.
 boolean contains(E element)
          Tests the existence of an element in the group.
 Comparator<E> getComparator()
          Returns the collection's sort order.
 ListenerList<SetListener<E>> getSetListeners()
          Returns the set listener collection.
 boolean isEmpty()
          Tests the emptiness of the group.
 Iterator<E> iterator()
           
 void remove(E element)
          Removes an element from the group.
 void setComparator(Comparator<E> comparator)
          Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hashSet

protected HashSet<E> hashSet
Constructor Detail

HashSet

public HashSet()

HashSet

public HashSet(Set<E> set)

HashSet

public HashSet(Comparator<E> comparator)
Method Detail

add

public void add(E element)
Description copied from interface: Group
Adds an element to the group.

Specified by:
add in interface Group<E>
Specified by:
add in interface Set<E>
Parameters:
element - The element to add to the group.
See Also:
SetListener.elementAdded(Set, Object)

remove

public void remove(E element)
Description copied from interface: Group
Removes an element from the group.

Specified by:
remove in interface Group<E>
Specified by:
remove in interface Set<E>
Parameters:
element - The element to remove from the set.
See Also:
SetListener.elementRemoved(Set, Object)

clear

public void clear()
Description copied from interface: Collection
Removes all elements from the collection.

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
See Also:
SetListener.setCleared(Set)

contains

public boolean contains(E element)
Description copied from interface: Group
Tests the existence of an element in the group.

Specified by:
contains in interface Group<E>
Parameters:
element - The element whose presence in the group is to be tested.
Returns:
true if the element exists in the group; false, otherwise.

isEmpty

public boolean isEmpty()
Description copied from interface: Group
Tests the emptiness of the group.

Specified by:
isEmpty in interface Group<E>
Returns:
true if the group contains no elements; false, otherwise.

getComparator

public Comparator<E> getComparator()
Description copied from interface: Collection
Returns the collection's sort order.

Specified by:
getComparator in interface Collection<E>
Returns:
The comparator used to order elements in the collection, or null if the sort order is undefined.
See Also:
Collection.setComparator(Comparator)

setComparator

public void setComparator(Comparator<E> comparator)
Description copied from interface: Collection
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.

Specified by:
setComparator in interface Collection<E>
Specified by:
setComparator in interface Set<E>
Parameters:
comparator - The comparator used to order elements in the collection, or null if the collection is unsorted.
See Also:
SetListener.setCleared(Set)

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>

getSetListeners

public ListenerList<SetListener<E>> getSetListeners()
Description copied from interface: Set
Returns the set listener collection.

Specified by:
getSetListeners in interface Set<E>