|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.collect.LazyRelationIndex<K,V>
public class LazyRelationIndex<K,V>
A RelationIndex implementation defined lazily in terms of the contents of a dynamic list of pairs.
Requires essentially no space, but is far less efficient than a ConcreteRelationIndex.
Does not support mutation. Defined for use in relations in which a particular mapping is unlikely
to be used heavily.
| Constructor Summary | |
|---|---|
LazyRelationIndex(java.lang.Iterable<? extends Pair<K,V>> pairs)
|
|
LazyRelationIndex(java.util.Set<Pair<K,V>> pairs)
|
|
| Method Summary | |
|---|---|
void |
added(K key,
V value)
Requests that the index be updated to reflect the addition of the given key/value pair. |
void |
cleared()
Requests that the index be cleared to reflect the current state of the relation. |
boolean |
contains(java.lang.Object key,
java.lang.Object value)
Whether the given key-value mapping occurs. |
boolean |
hasFixedSize()
true if this iterable is known to have a fixed size. |
boolean |
isEmpty()
Whether the iterable does not contain any elements. |
boolean |
isInfinite()
true if the iterable is known to have infinite size. |
boolean |
isStatic()
true if this iterable is unchanging. |
java.util.Iterator<Pair<K,V>> |
iterator()
Iterates through all key-value pairs in the index. |
PredicateSet<K> |
keys()
A dynamically-updating view of all keys mapping to at least one value. |
PredicateSet<V> |
match(K key)
A dynamically-updating view of all values matching key. |
void |
removed(K key,
V value)
Requests that the index be updated to reflect the removal of the given key/value pair. |
int |
size()
Compute the number of elements in the iterable. |
int |
size(int bound)
Compute the number of elements in the iterable, up to the given bound. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LazyRelationIndex(java.lang.Iterable<? extends Pair<K,V>> pairs)
public LazyRelationIndex(java.util.Set<Pair<K,V>> pairs)
| Method Detail |
|---|
public boolean isEmpty()
SizedIterable
isEmpty in interface SizedIterable<Pair<K,V>>public int size()
SizedIterableint, Integer.MAX_VALUE should be returned. Otherwise, next() may be safely invoked
on the iterator exactly this number of times.
size in interface SizedIterable<Pair<K,V>>public int size(int bound)
SizedIterablebound, bound is returned.
size in interface SizedIterable<Pair<K,V>>bound - Maximum result. Assumed to be nonnegative.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<Pair<K,V>>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<Pair<K,V>>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<Pair<K,V>>
public boolean contains(java.lang.Object key,
java.lang.Object value)
RelationIndex
contains in interface RelationIndex<K,V>public PredicateSet<K> keys()
RelationIndex
keys in interface RelationIndex<K,V>public PredicateSet<V> match(K key)
RelationIndexkey. May be empty. Mutation,
if supported, will be automatically reflected in the relation being indexed.
match in interface RelationIndex<K,V>public java.util.Iterator<Pair<K,V>> iterator()
RelationIndex
iterator in interface RelationIndex<K,V>iterator in interface java.lang.Iterable<Pair<K,V>>
public void added(K key,
V value)
RelationIndex
added in interface RelationIndex<K,V>
public void removed(K key,
V value)
RelationIndex
removed in interface RelationIndex<K,V>public void cleared()
RelationIndex
cleared in interface RelationIndex<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||