|
||||||||||
| 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<Pair<T1,T2>>
edu.rice.cs.plt.collect.AbstractRelation<T1,T2>
edu.rice.cs.plt.collect.AbstractInjectiveRelation<T1,T2>
edu.rice.cs.plt.collect.IndexedInjectiveRelation<T1,T2>
public class IndexedInjectiveRelation<T1,T2>
A hash code-based implementation of the InjectiveRelation interface. By default, a hash-based index is created mapping firsts to sets of seconds; this functionality may be turned off where it is not needed.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractInjectiveRelation |
|---|
AbstractInjectiveRelation.InverseInjectiveRelation |
| Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractRelation |
|---|
AbstractRelation.InverseRelation |
| Constructor Summary | |
|---|---|
IndexedInjectiveRelation()
Index in both directions using HashMaps and HashSets. |
|
IndexedInjectiveRelation(boolean indexFirst)
Index using HashMaps and HashSets. |
|
IndexedInjectiveRelation(Thunk<java.util.Map<T2,T1>> secondIndexFactory)
Create an index based on the given factory. |
|
IndexedInjectiveRelation(Thunk<java.util.Map<T2,T1>> secondIndexFactory,
Thunk<java.util.Map<T1,PredicateSet<T2>>> firstIndexFactory,
Thunk<java.util.Set<T2>> firstIndexEntryFactory)
Create indices based on the given factories. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(T1 first,
T2 second)
Add Pair.make(first, second) to the set. |
|
void |
clear()
|
|
PredicateSet<T1> |
firstSet()
The set of firsts. |
|
LambdaMap<T2,T1> |
injectionMap()
A map view of the relation, mapping seconds to firsts. |
|
boolean |
isStatic()
true if this iterable is unchanging. |
|
static
|
makeHashBased()
Make an IndexedInjectiveRelation indexed by HashMaps and HashSets. |
|
static
|
makeLinkedHashBased()
Make an IndexedInjectiveRelation indexed by LinkedHashMaps and LinkedHashSets. |
|
static
|
makeTreeBased()
Make an IndexedInjectiveRelation indexed by TreeMaps and TreeSets. |
|
PredicateSet<T2> |
matchFirst(T1 first)
The set of seconds corresponding to a specific first. |
|
boolean |
remove(T1 first,
T2 second)
Remove Pair.make(first, second) from the set. |
|
| Methods inherited from class edu.rice.cs.plt.collect.AbstractInjectiveRelation |
|---|
antecedent, contains, contains, containsSecond, hasFixedSize, inverse, isEmpty, isInfinite, iterator, matchSecond, secondSet, size, size |
| Methods inherited from class edu.rice.cs.plt.collect.AbstractRelation |
|---|
add, containsFirst, excludeFirsts, excludeSeconds, remove |
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface edu.rice.cs.plt.collect.InjectiveRelation |
|---|
add |
| Methods inherited from interface edu.rice.cs.plt.collect.Relation |
|---|
containsFirst, excludeFirsts, excludeSeconds, remove |
| Methods inherited from interface java.util.Set |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public IndexedInjectiveRelation()
HashMaps and HashSets.
public IndexedInjectiveRelation(boolean indexFirst)
HashMaps and HashSets. If indexFirst
is false, no first-to-second index is created.
public IndexedInjectiveRelation(Thunk<java.util.Map<T2,T1>> secondIndexFactory,
Thunk<java.util.Map<T1,PredicateSet<T2>>> firstIndexFactory,
Thunk<java.util.Set<T2>> firstIndexEntryFactory)
secondIndexFactory - Maps seconds to firsts.firstIndexFactory - Maps firsts to sets of seconds.firstIndexEntryFactory - Produces sets for the first-to-second index.public IndexedInjectiveRelation(Thunk<java.util.Map<T2,T1>> secondIndexFactory)
secondIndexFactory - Maps seconds to firsts.| Method Detail |
|---|
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<T1,T2>>isStatic in class AbstractInjectiveRelation<T1,T2>public LambdaMap<T2,T1> injectionMap()
InjectiveRelation
injectionMap in interface InjectiveRelation<T1,T2>injectionMap in class AbstractInjectiveRelation<T1,T2>public PredicateSet<T1> firstSet()
Relation
firstSet in interface Relation<T1,T2>firstSet in class AbstractInjectiveRelation<T1,T2>public PredicateSet<T2> matchFirst(T1 first)
Relation
matchFirst in interface Relation<T1,T2>matchFirst in class AbstractInjectiveRelation<T1,T2>
public boolean add(T1 first,
T2 second)
RelationPair.make(first, second) to the set.
add in interface InjectiveRelation<T1,T2>add in interface Relation<T1,T2>add in class AbstractRelation<T1,T2>
public boolean remove(T1 first,
T2 second)
RelationPair.make(first, second) from the set.
remove in interface Relation<T1,T2>remove in class AbstractRelation<T1,T2>public void clear()
clear in interface java.util.Collection<Pair<T1,T2>>clear in interface java.util.Set<Pair<T1,T2>>clear in class java.util.AbstractCollection<Pair<T1,T2>>public static <T1,T2> IndexedInjectiveRelation<T1,T2> makeHashBased()
HashMaps and HashSets.
public static <T1,T2> IndexedInjectiveRelation<T1,T2> makeLinkedHashBased()
LinkedHashMaps and LinkedHashSets.
public static <T1 extends java.lang.Comparable<? super T1>,T2 extends java.lang.Comparable<? super T2>> IndexedInjectiveRelation<T1,T2> makeTreeBased()
TreeMaps and TreeSets.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||