public class PersistentSet<T>
extends java.lang.Object
implements java.lang.Iterable<T>
PersistentSet implements a persistent set, based on a
persistent randomized treap. Unlike the Sets returned
by PersistentSetFactory, PersistentSet
does not implement that standard Set API
but instead exposes the underlying functional operations.| Constructor and Description |
|---|
PersistentSet()
Creates an empty
PersistentSet whose member objects
will all implement Comparable. |
PersistentSet(java.util.Comparator<T> c)
Creates an empty
PersistentSet whose member objects
are ordered by the given Comparator. |
| Modifier and Type | Method and Description |
|---|---|
PersistentSet<T> |
add(T element)
Creates and returns a new
PersistentSet 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.
|
java.util.Set<T> |
asSet()
Collections view of the set. |
PersistentSet<T> |
clone()
Cloning takes constant time, regardless of the size of the set.
|
boolean |
contains(T element)
Determines if the given element belongs to this set.
|
boolean |
isEmpty()
Determines if this
PersistentSet has any members. |
java.util.Iterator<T> |
iterator()
Unmodifiable iterator.
|
PersistentSet<T> |
remove(T 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. |
java.lang.String |
toString()
Human-readable representation of the set.
|
public PersistentSet()
PersistentSet whose member objects
will all implement Comparable. Note that
good hashcode implementations for the member objects are still
required.public PersistentSet(java.util.Comparator<T> c)
PersistentSet whose member objects
are ordered by the given Comparator. Note that
good hashcode implementations for the member objects are still
required.public boolean isEmpty()
PersistentSet has any members.public int size()
PersistentSet.public PersistentSet<T> add(T element)
PersistentSet identical to
this one, except it contains element.public boolean contains(T element)
public PersistentSet<T> remove(T element)
PersistentSet identical to this one,
except that it does not contain element.public PersistentSet<T> addAll(PersistentSet<T> set)
public PersistentSet<T> clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>public java.util.Set<T> asSet()
Collections view of the set.Copyright (c) 2006 C. Scott Ananian