|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<T>
edu.rice.cs.plt.collect.DelegatingCollection<T>
edu.rice.cs.plt.collect.DelegatingSet<Pair<T1,T2>>
edu.rice.cs.plt.collect.DelegatingRelation<T1,T2>
edu.rice.cs.plt.collect.ImmutableRelation<T1,T2>
public class ImmutableRelation<T1,T2>
Wraps a relation in an immutable interface. Analogous to Collections.unmodifiableMap(java.util.Map extends K, ? extends V>).
Note that only only this interface with the data is immutable -- if the original data
structure is mutable, a client with direct access to that structure can still mutate it.
Subclasses can invoke the overridden methods in AbstractCollection to use the
default implementations there by invoking, for example, DelegatingCollection.abstractCollectionAddAll(java.util.Collection extends T>)
(see AbstractCollection for details on the default implementations).
| Field Summary |
|---|
| Fields inherited from class edu.rice.cs.plt.collect.DelegatingRelation |
|---|
_delegate |
| Constructor Summary | |
|---|---|
ImmutableRelation(Relation<T1,T2> relation)
|
|
| Method Summary | ||
|---|---|---|
boolean |
add(Pair<T1,T2> o)
Add Pair.make(p.first(), p.second()) to the set. |
|
boolean |
add(T1 first,
T2 second)
Add Pair.make(first, second) to the set. |
|
boolean |
addAll(Collection<? extends Pair<T1,T2>> c)
|
|
void |
clear()
|
|
boolean |
contains(T1 first,
T2 second)
Whether Pair.make(first, second) appears in the set. |
|
boolean |
containsFirst(T1 first)
Whether a pair with the given first value appears in the set. |
|
boolean |
containsSecond(T2 second)
Whether a pair with the given second value appears in the set. |
|
PredicateSet<T2> |
excludeFirsts()
The set of seconds for which there exists a (first, second) pair in the relation. |
|
PredicateSet<T1> |
excludeSeconds()
The set of firsts for which there exists a (first, second) pair in the relation. |
|
PredicateSet<T1> |
firstSet()
The set of firsts. |
|
Relation<T2,T1> |
inverse()
Produce the inverse of the relation, derived by swapping the elements of each pair. |
|
static
|
make(Relation<T1,T2> relation)
Call the constructor (allows T1 and T2 to be inferred). |
|
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(Object o)
If o is a pair, remove Pair.make(o.first(), o.second()) from the set. |
|
boolean |
remove(T1 first,
T2 second)
Remove Pair.make(first, second) from the set. |
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
PredicateSet<T2> |
secondSet()
The set of seconds. |
|
| Methods inherited from class edu.rice.cs.plt.collect.DelegatingRelation |
|---|
hasFixedSize, isInfinite, isStatic, size |
| Methods inherited from class edu.rice.cs.plt.collect.DelegatingSet |
|---|
equals, hashCode |
| Methods inherited from class edu.rice.cs.plt.collect.DelegatingCollection |
|---|
abstractCollectionAddAll, abstractCollectionClear, abstractCollectionContains, abstractCollectionContainsAll, abstractCollectionIsEmpty, abstractCollectionRemove, abstractCollectionRemoveAll, abstractCollectionRetainAll, abstractCollectionToArray, abstractCollectionToArray, compositeHeight, compositeSize, contains, containsAll, isEmpty, iterator, size, 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.Relation |
|---|
contains |
| Methods inherited from interface java.util.Set |
|---|
containsAll, equals, hashCode, isEmpty, iterator, size, toArray, toArray |
| Methods inherited from interface edu.rice.cs.plt.iter.SizedIterable |
|---|
isEmpty, size |
| Constructor Detail |
|---|
public ImmutableRelation(Relation<T1,T2> relation)
| Method Detail |
|---|
public boolean add(Pair<T1,T2> o)
RelationPair.make(p.first(), p.second()) to the set. (That is, the pair that is
added is not an instance of some subclass of Pair.)
add in interface Relation<T1,T2>add in interface Collection<Pair<T1,T2>>add in interface Set<Pair<T1,T2>>add in class DelegatingCollection<Pair<T1,T2>>public boolean remove(Object o)
Relationo is a pair, remove Pair.make(o.first(), o.second()) from the set.
(That is, equality is always defined according to the Pair class's equals method, not
that of some subclass.)
remove in interface Relation<T1,T2>remove in interface Collection<Pair<T1,T2>>remove in interface Set<Pair<T1,T2>>remove in class DelegatingCollection<Pair<T1,T2>>public boolean addAll(Collection<? extends Pair<T1,T2>> c)
addAll in interface Collection<Pair<T1,T2>>addAll in interface Set<Pair<T1,T2>>addAll in class DelegatingCollection<Pair<T1,T2>>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<Pair<T1,T2>>retainAll in interface Set<Pair<T1,T2>>retainAll in class DelegatingCollection<Pair<T1,T2>>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<Pair<T1,T2>>removeAll in interface Set<Pair<T1,T2>>removeAll in class DelegatingCollection<Pair<T1,T2>>public void clear()
clear in interface Collection<Pair<T1,T2>>clear in interface Set<Pair<T1,T2>>clear in class DelegatingCollection<Pair<T1,T2>>
public boolean contains(T1 first,
T2 second)
RelationPair.make(first, second) appears in the set.
contains in interface Relation<T1,T2>contains in interface Predicate2<T1,T2>contains in class DelegatingRelation<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 DelegatingRelation<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 DelegatingRelation<T1,T2>public Relation<T2,T1> inverse()
Relation
inverse in interface Relation<T1,T2>inverse in class DelegatingRelation<T1,T2>public PredicateSet<T1> firstSet()
Relation
firstSet in interface Relation<T1,T2>firstSet in class DelegatingRelation<T1,T2>public boolean containsFirst(T1 first)
Relation
containsFirst in interface Relation<T1,T2>containsFirst in class DelegatingRelation<T1,T2>public PredicateSet<T2> matchFirst(T1 first)
Relation
matchFirst in interface Relation<T1,T2>matchFirst in class DelegatingRelation<T1,T2>public PredicateSet<T2> excludeFirsts()
RelationRelation.secondSet(), but defined redundantly for consistency
with higher-arity relations. Need not allow mutation, but must reflect subsequent changes.
excludeFirsts in interface Relation<T1,T2>excludeFirsts in class DelegatingRelation<T1,T2>public PredicateSet<T2> secondSet()
Relation
secondSet in interface Relation<T1,T2>secondSet in class DelegatingRelation<T1,T2>public boolean containsSecond(T2 second)
Relation
containsSecond in interface Relation<T1,T2>containsSecond in class DelegatingRelation<T1,T2>public PredicateSet<T1> matchSecond(T2 second)
Relation
matchSecond in interface Relation<T1,T2>matchSecond in class DelegatingRelation<T1,T2>public PredicateSet<T1> excludeSeconds()
RelationRelation.firstSet(), but defined redundantly for consistency
with higher-arity relations. Need not allow mutation, but must reflect subsequent changes.
excludeSeconds in interface Relation<T1,T2>excludeSeconds in class DelegatingRelation<T1,T2>public static <T1,T2> ImmutableRelation<T1,T2> make(Relation<T1,T2> relation)
T1 and T2 to be inferred).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||