|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.collect.ConcreteRelationIndex<K,V>
public class ConcreteRelationIndex<K,V>
A RelationIndex implementation that maintains concrete data structures to index the contents of
the relation. To support mutation in other indices to reflect changes made directly to
sets and iterators produced by this index, clients should override the addToRelation(K, V),
removeFromRelation(K, V), and clearRelation() methods.
Keys must have a valid hashCode() implementation.
| Constructor Summary | |
|---|---|
ConcreteRelationIndex(Thunk<? extends java.util.Map<K,PredicateSet<V>>> mapFactory,
Thunk<? extends java.util.Set<V>> setFactory)
Create an empty ConcreteRelationIndex. |
|
| Method Summary | |
|---|---|
void |
added(K key,
V value)
Requests that the index be updated to reflect the addition of the given key/value pair. |
protected void |
addToRelation(K key,
V value)
Add the given entry to the relation. |
void |
cleared()
Requests that the index be cleared to reflect the current state of the relation. |
protected void |
clearRelation()
Clear 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. |
protected void |
removeFromRelation(K key,
V value)
Remove the given entry from the relation. |
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. |
protected void |
validateAdd(K key,
V value)
Checks that the given pair, which does not appear in this index, can be added to the relation. |
protected void |
validateClear()
Checks that the relation can be cleared. |
protected void |
validateRemove(K key,
V value)
Checks that the given pair, which appears in this index, can be removed from the relation. |
protected void |
validateRemoveKey(K key,
PredicateSet<V> vals)
Checks that the given key, which appears with at least one value in this index, can be removed with all associated values from the relation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConcreteRelationIndex(Thunk<? extends java.util.Map<K,PredicateSet<V>>> mapFactory,
Thunk<? extends java.util.Set<V>> setFactory)
mapFactory - Produces an empty map for mapping keys to sets of values. The mutability
of keys() corresponds to this map's keySet()'s mutability.setFactory - Produces an initial set to hold values associated with a key.| Method Detail |
|---|
protected void validateAdd(K key,
V value)
protected void addToRelation(K key,
V value)
protected void validateRemove(K key,
V value)
protected void validateRemoveKey(K key,
PredicateSet<V> vals)
protected void removeFromRelation(K key,
V value)
protected void validateClear()
protected void clearRelation()
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 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 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 | |||||||||