lu.cs.co.util
Class Set

java.lang.Object
  |
  +--lu.cs.co.util.Set

public class Set
extends Object

A very simple class for sets. Supports insertions and picking an element from the set. The sets are actually multisets: No checks for duplicates are performed.

For more powerful sets consult the Collection classes of Java 1.2

See Also:
Set

Constructor Summary
Set()
          Constructs an empty set.
Set(int size)
          Constructs an empty set.
 
Method Summary
 Object anyElement()
          Removes an element from the set assuming it is nonempty.
 Enumeration elements()
          Constructs and enumeration of the elements in the set.
 void insert(Object o)
          Inserts a given element into the set.
 boolean isEmpty()
           
 int size()
          Returns this set's cardinality (number of elements):
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Set

public Set()
Constructs an empty set.

Set

public Set(int size)
Constructs an empty set.
Parameters:
size - an estimate of the maximium size of the set.
Method Detail

insert

public void insert(Object o)
Inserts a given element into the set. Duplicates are not detected.
Parameters:
the - given element

isEmpty

public boolean isEmpty()

anyElement

public Object anyElement()
Removes an element from the set assuming it is nonempty.
Returns:
the removed element
Throws:
UnderflowException - if the set is empty

elements

public Enumeration elements()
Constructs and enumeration of the elements in the set.
Returns:
an enumeration of the set.
See Also:
Enumeration

size

public int size()
Returns this set's cardinality (number of elements):