Class Set

java.lang.Object
  |
  +--Set

public class Set
extends java.lang.Object

A set of non-null objects. The set is based on an array, and will grow as needed to accomodate additional items.


Constructor Summary
Set()
          Constructs a set with an initial size of 32 elements.
Set(int size)
          Constructs a set with room for size elements.
 
Method Summary
 void add(java.lang.Object obj)
          Add an object to the set.
 void clear()
          Clears the set.
 boolean empty()
          Is the set empty?
 boolean member(java.lang.Object obj)
          Compares obj to the item is the set to determine if obj is already a member of the set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Set

public Set()
Constructs a set with an initial size of 32 elements.

Set

public Set(int size)
Constructs a set with room for size elements. The set will grow as needed.
Parameters:
size - the initial size.
Method Detail

empty

public boolean empty()
Is the set empty?
Returns:
true if the set is empty.

member

public boolean member(java.lang.Object obj)
Compares obj to the item is the set to determine if obj is already a member of the set. The objects are compared using equals.
Parameters:
obj - the object to test.
Returns:
true if the object is already a member.

add

public void add(java.lang.Object obj)
Add an object to the set. The object is only added if it's non-null.

clear

public void clear()
Clears the set.