edu.rice.cs.plt.collect
Class AbstractOneToOneRelation<T1,T2>
java.lang.Object
java.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.AbstractFunctionalRelation<T1,T2>
edu.rice.cs.plt.collect.AbstractOneToOneRelation<T1,T2>
- All Implemented Interfaces:
- FunctionalRelation<T1,T2>, InjectiveRelation<T1,T2>, OneToOneRelation<T1,T2>, PredicateSet<Pair<T1,T2>>, Relation<T1,T2>, SizedIterable<Pair<T1,T2>>, Lambda<T1,T2>, Predicate<Object>, Predicate2<T1,T2>, Iterable<Pair<T1,T2>>, Collection<Pair<T1,T2>>, Set<Pair<T1,T2>>
- Direct Known Subclasses:
- IndexedOneToOneRelation, SingletonRelation
public abstract class AbstractOneToOneRelation<T1,T2>
- extends AbstractFunctionalRelation<T1,T2>
- implements OneToOneRelation<T1,T2>
An abstract parent class for implementations of OneToOneRelation. Subclasses must provide
isStatic()
, functionMap()
, and injectionMap()
. To support mutation,
they must also override AbstractRelation.add(Object, Object)
and AbstractRelation.remove(Object, Object)
.
For best performance, they may also override AbstractCollection.clear()
.
Methods inherited from class edu.rice.cs.plt.collect.AbstractFunctionalRelation |
contains, contains, containsFirst, firstSet, hasFixedSize, isEmpty, isInfinite, iterator, matchFirst, size, size, value |
Methods inherited from interface java.util.Set |
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray |
AbstractOneToOneRelation
public AbstractOneToOneRelation()
isStatic
public abstract boolean isStatic()
- Description copied from interface:
SizedIterable
true
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.)
- Specified by:
isStatic
in interface SizedIterable<Pair<T1,T2>>
- Specified by:
isStatic
in class AbstractFunctionalRelation<T1,T2>
functionMap
public abstract LambdaMap<T1,T2> functionMap()
- Description copied from interface:
FunctionalRelation
- A map view of the relation, mapping firsts to seconds. Need not allow mutation, but must
reflect subsequent changes.
- Specified by:
functionMap
in interface FunctionalRelation<T1,T2>
- Specified by:
functionMap
in class AbstractFunctionalRelation<T1,T2>
injectionMap
public abstract LambdaMap<T2,T1> injectionMap()
- Description copied from interface:
InjectiveRelation
- A map view of the relation, mapping seconds to firsts. Need not allow mutation, but must
reflect subsequent changes.
- Specified by:
injectionMap
in interface InjectiveRelation<T1,T2>
secondSet
public PredicateSet<T2> secondSet()
- Returns
injectionMap().keySet()
.
- Specified by:
secondSet
in interface Relation<T1,T2>
- Specified by:
secondSet
in class AbstractFunctionalRelation<T1,T2>
containsSecond
public boolean containsSecond(T2 second)
- Returns
injectionMap().containsKey(second)
.
- Specified by:
containsSecond
in interface Relation<T1,T2>
- Overrides:
containsSecond
in class AbstractRelation<T1,T2>
matchSecond
public PredicateSet<T1> matchSecond(T2 second)
- Returns a set that queries and manipulates the mapping from
second
in injectionMap()
.
- Specified by:
matchSecond
in interface InjectiveRelation<T1,T2>
- Specified by:
matchSecond
in interface Relation<T1,T2>
- Specified by:
matchSecond
in class AbstractFunctionalRelation<T1,T2>
antecedent
public T1 antecedent(T2 second)
- Returns
injectionMap().get(first)
.
- Specified by:
antecedent
in interface InjectiveRelation<T1,T2>
inverse
public OneToOneRelation<T2,T1> inverse()
- Returns an
AbstractOneToOneRelation.InverseOneToOneRelation
.
- Specified by:
inverse
in interface FunctionalRelation<T1,T2>
- Specified by:
inverse
in interface InjectiveRelation<T1,T2>
- Specified by:
inverse
in interface OneToOneRelation<T1,T2>
- Specified by:
inverse
in interface Relation<T1,T2>
- Overrides:
inverse
in class AbstractFunctionalRelation<T1,T2>