|
||||||||||
| 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.UnindexedRelation<T1,T2>
public class UnindexedRelation<T1,T2>
A mutable relation implemented by wrapping a set of pairs. The iteration order and performance
characteristics of the relation match that of the underlying set. Lookup operations like
#matchFirst() are not optimized with an index, and thus have poor performance. This class
is useful when the relation is expected to be small, or when low allocation cost, a small memory
footprint, and iteration order are more important than performance of index-related operations.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractRelation |
|---|
AbstractRelation.InverseRelation |
| Constructor Summary | |
|---|---|
UnindexedRelation()
Create an UnindexedRelation wrapping a HashSet. |
|
UnindexedRelation(Thunk<java.util.Set<Pair<T1,T2>>> setFactory)
Create an UnindexedRelation wrapping an instance of the provided set. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(T1 first,
T2 second)
Add Pair.make(first, second) to the set. |
|
void |
clear()
|
|
boolean |
contains(java.lang.Object obj)
Test whether the set contains an object. |
|
boolean |
contains(T1 first,
T2 second)
Tests whether the given objects appear as a pair in this relation. |
|
PredicateSet<T1> |
firstSet()
The set of firsts. |
|
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. |
|
java.util.Iterator<Pair<T1,T2>> |
iterator()
|
|
static
|
makeHashBased()
Make an UnindexedRelation wrapping a HashSet. |
|
static
|
makeLinkedHashBased()
Make an UnindexedRelation wrapping a LinkedHashSet. |
|
static
|
makeTreeBased()
Make an UnindexedRelation wrapping a TreeSet. |
|
PredicateSet<T2> |
matchFirst(T1 first)
The set of seconds corresponding to a specific first. |
|
PredicateSet<T1> |
matchSecond(T2 second)
The set of firsts corresponding to a specific second. |
|
boolean |
remove(T1 first,
T2 second)
Remove Pair.make(first, second) from the set. |
|
PredicateSet<T2> |
secondSet()
The set of seconds. |
|
int |
size()
Returns size(Integer.MAX_VALUE). |
|
| Methods inherited from class edu.rice.cs.plt.collect.AbstractRelation |
|---|
add, containsFirst, containsSecond, excludeFirsts, excludeSeconds, inverse, remove |
| Methods inherited from class edu.rice.cs.plt.collect.AbstractPredicateSet |
|---|
size |
| 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 java.util.Set |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface edu.rice.cs.plt.iter.SizedIterable |
|---|
size |
| Constructor Detail |
|---|
public UnindexedRelation()
public UnindexedRelation(Thunk<java.util.Set<Pair<T1,T2>>> setFactory)
| Method Detail |
|---|
public boolean isEmpty()
AbstractPredicateSetsize(1) == 0.
isEmpty in interface SizedIterable<Pair<T1,T2>>isEmpty in interface java.util.Collection<Pair<T1,T2>>isEmpty in interface java.util.Set<Pair<T1,T2>>isEmpty in class AbstractPredicateSet<Pair<T1,T2>>public int size()
AbstractPredicateSetsize(Integer.MAX_VALUE).
size in interface SizedIterable<Pair<T1,T2>>size in interface java.util.Collection<Pair<T1,T2>>size in interface java.util.Set<Pair<T1,T2>>size in class AbstractPredicateSet<Pair<T1,T2>>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<T1,T2>>hasFixedSize in class AbstractRelation<T1,T2>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<T1,T2>>isInfinite in class AbstractRelation<T1,T2>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 AbstractRelation<T1,T2>
public boolean contains(T1 first,
T2 second)
AbstractRelationT1 and T2 because the Collection.contains(java.lang.Object)
method allows arbitrary objects.
contains in interface Relation<T1,T2>contains in interface Predicate2<T1,T2>contains in class AbstractRelation<T1,T2>public boolean contains(java.lang.Object obj)
AbstractPredicateSetAbstractCollection.contains(java.lang.Object)) is a linear search,
which is almost always unreasonable for a set.
contains in interface Relation<T1,T2>contains in interface Predicate<java.lang.Object>contains in interface java.util.Collection<Pair<T1,T2>>contains in interface java.util.Set<Pair<T1,T2>>contains in class AbstractRelation<T1,T2>public java.util.Iterator<Pair<T1,T2>> iterator()
iterator in interface java.lang.Iterable<Pair<T1,T2>>iterator in interface java.util.Collection<Pair<T1,T2>>iterator in interface java.util.Set<Pair<T1,T2>>iterator in class AbstractRelation<T1,T2>
public boolean add(T1 first,
T2 second)
RelationPair.make(first, second) to the set.
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 PredicateSet<T1> firstSet()
Relation
firstSet in interface Relation<T1,T2>firstSet in class AbstractRelation<T1,T2>public PredicateSet<T2> matchFirst(T1 first)
Relation
matchFirst in interface Relation<T1,T2>matchFirst in class AbstractRelation<T1,T2>public PredicateSet<T2> secondSet()
Relation
secondSet in interface Relation<T1,T2>secondSet in class AbstractRelation<T1,T2>public PredicateSet<T1> matchSecond(T2 second)
Relation
matchSecond in interface Relation<T1,T2>matchSecond in class AbstractRelation<T1,T2>public static <T1,T2> UnindexedRelation<T1,T2> makeHashBased()
HashSet.
public static <T1,T2> UnindexedRelation<T1,T2> makeLinkedHashBased()
LinkedHashSet.
public static <T1 extends java.lang.Comparable<? super T1>,T2 extends java.lang.Comparable<? super T2>> UnindexedRelation<T1,T2> makeTreeBased()
TreeSet.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||