edu.rice.cs.plt.collect
Interface OneToOneRelation<T1,T2>

All Superinterfaces:
java.util.Collection<Pair<T1,T2>>, FunctionalRelation<T1,T2>, InjectiveRelation<T1,T2>, java.lang.Iterable<Pair<T1,T2>>, Lambda<T1,T2>, Predicate<java.lang.Object>, Predicate2<T1,T2>, PredicateSet<Pair<T1,T2>>, Relation<T1,T2>, java.util.Set<Pair<T1,T2>>, SizedIterable<Pair<T1,T2>>
All Known Implementing Classes:
AbstractOneToOneRelation, AbstractOneToOneRelation.InverseOneToOneRelation, EmptyRelation, IndexedOneToOneRelation, SingletonRelation

public interface OneToOneRelation<T1,T2>
extends FunctionalRelation<T1,T2>, InjectiveRelation<T1,T2>

A injective functional relation: each first (of type T1) corresponds to at most one second (of type T2), and vice versa. The inverse of a one-to-one relation is also a one-to-one relation.


Method Summary
 boolean add(Pair<T1,T2> pair)
          Add a pair to the set.
 boolean add(T1 first, T2 second)
          Add Pair.make(first, second) to the set.
 OneToOneRelation<T2,T1> inverse()
          Produce the inverse of the relation, derived by swapping the elements of each pair.
 
Methods inherited from interface edu.rice.cs.plt.collect.FunctionalRelation
functionMap, matchFirst, value
 
Methods inherited from interface edu.rice.cs.plt.collect.InjectiveRelation
antecedent, injectionMap, matchSecond
 
Methods inherited from interface edu.rice.cs.plt.collect.Relation
contains, contains, containsFirst, containsSecond, excludeFirsts, excludeSeconds, firstSet, remove, remove, secondSet
 
Methods inherited from interface java.util.Set
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface edu.rice.cs.plt.iter.SizedIterable
hasFixedSize, isEmpty, isInfinite, isStatic, size, size
 

Method Detail

add

boolean add(Pair<T1,T2> pair)
Add a pair to the set. If the pair violates the cardinality constraint, throw an exception.

Specified by:
add in interface java.util.Collection<Pair<T1,T2>>
Specified by:
add in interface FunctionalRelation<T1,T2>
Specified by:
add in interface InjectiveRelation<T1,T2>
Specified by:
add in interface Relation<T1,T2>
Specified by:
add in interface java.util.Set<Pair<T1,T2>>
Throws:
java.lang.IllegalArgumentException - If containsFirst(pair.first()) or containsSecond(pair.second()) but not contains(pair).

add

boolean add(T1 first,
            T2 second)
Add Pair.make(first, second) to the set. If the pair violates the cardinality constraint, throw an exception.

Specified by:
add in interface FunctionalRelation<T1,T2>
Specified by:
add in interface InjectiveRelation<T1,T2>
Specified by:
add in interface Relation<T1,T2>
Throws:
java.lang.IllegalArgumentException - If containsFirst(first) or containsSecond(second) but not contains(first, second).

inverse

OneToOneRelation<T2,T1> inverse()
Produce the inverse of the relation, derived by swapping the elements of each pair. Note that the inverse is one-to-one. Need not allow mutation, but must reflect subsequent changes.

Specified by:
inverse in interface FunctionalRelation<T1,T2>
Specified by:
inverse in interface InjectiveRelation<T1,T2>
Specified by:
inverse in interface Relation<T1,T2>