net.cscott.jutil

Class PersistentSet<T>

public class PersistentSet<T> extends Object

PersistentSet implements a persistent set, based on a persistent randomized treap.

Version: $Id: PersistentSet.java,v 1.2 2004/01/13 01:28:37 cananian Exp $

Author: C. Scott Ananian

Constructor Summary
PersistentSet()
Creates an empty PersistentSet whose member objects will all implement java.lang.Comparable.
PersistentSet(Comparator<T> c)
Creates an empty PersistentSet whose member objects are ordered by the given Comparator.
Method Summary
PersistentSet<T>add(T element)
Creates and returns a new PersistantSet identical to this one, except it contains element.
PersistentSet<T>addAll(PersistentSet<T> set)
Add all the items in the given set to this set.
Set<T>asSet()
java.util.Collections view of the set.
booleancontains(T element)
Determines if the given element belongs to this set.
booleanisEmpty()
Determines if this PersistentSet has any members.
PersistentSet<T>remove(T element)
Make a new PersistentSet identical to this one, except that it does not contain element.
intsize()
Count the number of elements in this PersistentSet.
StringtoString()
Human-readable representation of the set.

Constructor Detail

PersistentSet

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

PersistentSet

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

Method Detail

add

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

addAll

public PersistentSet<T> addAll(PersistentSet<T> set)
Add all the items in the given set to this set.

asSet

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

contains

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

isEmpty

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

remove

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

size

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

toString

public String toString()
Human-readable representation of the set.
Copyright © 2003 C. Scott Ananian