|
||||||||||
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.IterableSet<E>
public class IterableSet<E>
A Set wrapping an Iterable. Allows iterables to be viewed as sets without creating a
copy, and reflects subsequent changes made to the iterable. Does not support mutation.
Since duplicate elements must be lazily skipped, most operations (including size()
and contains
) require a traversal of the iterable, and thus have relatively poor
performance.
Constructor Summary | |
---|---|
IterableSet(Iterable<? extends E> iter)
|
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()
Must store all previously-seen elements in order to skip duplicates. |
Methods inherited from class edu.rice.cs.plt.collect.AbstractPredicateSet |
---|
size, size |
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 IterableSet(Iterable<? extends E> iter)
Method Detail |
---|
public boolean contains(Object o)
AbstractPredicateSet
AbstractCollection.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 int compositeHeight()
Composite
compositeHeight
in interface Composite
public int compositeSize()
Composite
compositeSize
in interface Composite
public Iterator<E> iterator()
next()
invocations.
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface Set<E>
iterator
in class AbstractCollection<E>
public boolean isInfinite()
SizedIterable
true
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()
SizedIterable
true
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()
SizedIterable
true
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 boolean isEmpty()
AbstractPredicateSet
size(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 |