|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<T>
edu.rice.cs.plt.collect.AbstractPredicateSet<E>
edu.rice.cs.plt.collect.UnionSet<E>
public class UnionSet<E>
The union of two sets, lazily constructed and updated dynamically.
| Constructor Summary | |
|---|---|
UnionSet(Set<? extends E> set1,
Set<? extends E> set2)
For best performance of size(), set2 should be the smaller
of the two sets (this is not handled automatically because calculating sizes may be expensive). |
|
| Method Summary | |
|---|---|
int |
compositeHeight()
Get the maximum path length from this node to a leaf. |
int |
compositeSize()
Get the number of nodes in the tree rooted at this node. |
boolean |
contains(Object o)
Test whether the set contains an object. |
boolean |
hasFixedSize()
true if this iterable is known to have a fixed size. |
boolean |
isEmpty()
Returns size(1) == 0. |
boolean |
isInfinite()
true if the iterable is known to have infinite size. |
boolean |
isStatic()
true if this iterable is unchanging. |
Iterator<E> |
iterator()
|
int |
size()
Linear in the size of set2. |
int |
size(int bound)
Computes the size by traversing the iterator (requires linear time). |
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
add, addAll, clear, containsAll, remove, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
add, addAll, clear, containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public UnionSet(Set<? extends E> set1,
Set<? extends E> set2)
size(), set2 should be the smaller
of the two sets (this is not handled automatically because calculating sizes may be expensive).
| Method Detail |
|---|
public int compositeHeight()
Composite
compositeHeight in interface Compositepublic int compositeSize()
Composite
compositeSize in interface Compositepublic boolean contains(Object o)
AbstractPredicateSetAbstractCollection.contains(java.lang.Object)) is a linear search,
which is almost always unreasonable for a set.
contains in interface Predicate<Object>contains in interface Collection<E>contains in interface Set<E>contains in class AbstractPredicateSet<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class AbstractCollection<E>public boolean isInfinite()
SizedIterabletrue if the iterable is known to have infinite size. If true, an iterator over the iterable in its
current state will never return false from hasNext().
isInfinite in interface SizedIterable<E>public boolean hasFixedSize()
SizedIterabletrue if this iterable is known to have a fixed size. This is the case if the iterable is immutable,
or if changes can only replace values, not remove or add them. An infinite iterable may be fixed if it
is guaranteed to never become finite.
hasFixedSize in interface SizedIterable<E>public boolean isStatic()
SizedIterabletrue if this iterable is unchanging. This implies that hasFixedSize() is true, and that
iterator() will always return the same (either == or equal() and immutable) elements
in the same order. ("Immutable" here means that equals() invocations are consistent over time -- if
two objects are equal, they will never become inequal, and vice versa.)
isStatic in interface SizedIterable<E>public int size()
set2.
size in interface SizedIterable<E>size in interface Collection<E>size in interface Set<E>size in class AbstractPredicateSet<E>public int size(int bound)
AbstractPredicateSet
size in interface SizedIterable<E>size in class AbstractPredicateSet<E>bound - Maximum result. Assumed to be nonnegative.public boolean isEmpty()
AbstractPredicateSetsize(1) == 0.
isEmpty in interface SizedIterable<E>isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractPredicateSet<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||