harpoon.Util.Collections
Class PersistentSet

java.lang.Object
  |
  +--harpoon.Util.Collections.PersistentSet

public class PersistentSet
extends Object

PersistentSet implements a persistent set, based on a binary search tree.

Version:
$Id: PersistentSet.java,v 1.2 2002/02/25 21:09:15 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Summary
PersistentSet()
          Creates an empty PersistentSet whose member objects will all implement java.lang.Comparable.
PersistentSet(Comparator c)
          Creates an empty PersistentSet whose member objects are ordered by the given Comparator.
 
Method Summary
 PersistentSet add(Object element)
          Creates and returns a new PersistantSet identical to this one, except it contains element.
 Set asSet()
          java.util.Collections view of the set.
 boolean contains(Object element)
          Determines if the given element belongs to this set.
 boolean isEmpty()
          Determines if this PersistentSet has any members.
 PersistentSet remove(Object element)
          Make a new PersistentSet identical to this one, except that it does not contain element.
 int size()
          Count the number of elements in this PersistentSet.
 String toString()
          Human-readable representation of the set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistentSet

public PersistentSet()
Creates an empty PersistentSet whose member objects will all implement java.lang.Comparable.


PersistentSet

public PersistentSet(Comparator c)
Creates an empty PersistentSet whose member objects are ordered by the given Comparator.

Method Detail

isEmpty

public boolean isEmpty()
Determines if this PersistentSet has any members.


size

public int size()
Count the number of elements in this PersistentSet.


add

public PersistentSet add(Object element)
Creates and returns a new PersistantSet identical to this one, except it contains element.


contains

public boolean contains(Object element)
Determines if the given element belongs to this set.


remove

public PersistentSet remove(Object element)
Make a new PersistentSet identical to this one, except that it does not contain element.


toString

public String toString()
Human-readable representation of the set.

Overrides:
toString in class Object

asSet

public Set asSet()
java.util.Collections view of the set.