weiss.util
Class HashSet

java.lang.Object
  |
  +--weiss.util.AbstractCollection
        |
        +--weiss.util.HashSet
All Implemented Interfaces:
Collection, java.io.Serializable, Set

public class HashSet
extends AbstractCollection
implements Set

HashSet implementation. Matches are based on equals; and hashCode must be consistently defined.

See Also:
Serialized Form

Constructor Summary
HashSet()
          Construct an empty HashSet.
HashSet(Collection other)
          Construct a HashSet from any collection.
 
Method Summary
 boolean add(java.lang.Object x)
          Adds an item to this collection.
 void clear()
          Change the size of this collection to zero.
 boolean contains(java.lang.Object x)
          Tests if some item is in this collection.
 java.lang.Object getMatch(java.lang.Object x)
          This method is not part of standard Java 1.2.
 Iterator iterator()
          Obtains an Iterator object used to traverse the collection.
 boolean remove(java.lang.Object x)
          Removes an item from this collection.
 int size()
          Returns the number of items in this collection.
 
Methods inherited from class weiss.util.AbstractCollection
equals, hashCode, isEmpty, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface weiss.util.Collection
isEmpty, toArray
 

Constructor Detail

HashSet

public HashSet()
Construct an empty HashSet.

HashSet

public HashSet(Collection other)
Construct a HashSet from any collection.
Method Detail

size

public int size()
Returns the number of items in this collection.
Specified by:
size in interface Collection
Returns:
the number of items in this collection.

getMatch

public java.lang.Object getMatch(java.lang.Object x)
This method is not part of standard Java 1.2. Like contains, it checks if x is in the set. If it is, it returns the reference to the matching object; otherwise it returns null.
Specified by:
getMatch in interface Set
Parameters:
x - the object to search for.
Returns:
if contains(x) is false, the return value is null; otherwise, the return value is the object that causes contains(x) to return true.

contains

public boolean contains(java.lang.Object x)
Tests if some item is in this collection.
Specified by:
contains in interface Collection
Overrides:
contains in class AbstractCollection
Parameters:
x - any object.
Returns:
true if this collection contains an item equal to x.

add

public boolean add(java.lang.Object x)
Adds an item to this collection.
Specified by:
add in interface Collection
Parameters:
x - any object.
Returns:
true if this item was added to the collection.

remove

public boolean remove(java.lang.Object x)
Removes an item from this collection.
Specified by:
remove in interface Collection
Overrides:
remove in class AbstractCollection
Parameters:
x - any object.
Returns:
true if this item was removed from the collection.

clear

public void clear()
Change the size of this collection to zero.
Specified by:
clear in interface Collection
Overrides:
clear in class AbstractCollection

iterator

public Iterator iterator()
Obtains an Iterator object used to traverse the collection.
Specified by:
iterator in interface Collection