edu.rice.cs.plt.collect
Class SingletonRelation<T1,T2>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<T>
          extended by edu.rice.cs.plt.collect.AbstractPredicateSet<Pair<T1,T2>>
              extended by edu.rice.cs.plt.collect.AbstractRelation<T1,T2>
                  extended by edu.rice.cs.plt.collect.AbstractFunctionalRelation<T1,T2>
                      extended by edu.rice.cs.plt.collect.AbstractOneToOneRelation<T1,T2>
                          extended by edu.rice.cs.plt.collect.SingletonRelation<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<java.lang.Object>, Predicate2<T1,T2>, java.io.Serializable, java.lang.Iterable<Pair<T1,T2>>, java.util.Collection<Pair<T1,T2>>, java.util.Set<Pair<T1,T2>>

public class SingletonRelation<T1,T2>
extends AbstractOneToOneRelation<T1,T2>
implements java.io.Serializable

An immutable Relation containing a single pair.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractOneToOneRelation
AbstractOneToOneRelation.InverseOneToOneRelation
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractFunctionalRelation
AbstractFunctionalRelation.InverseFunctionalRelation
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.AbstractRelation
AbstractRelation.InverseRelation
 
Constructor Summary
SingletonRelation(Pair<? extends T1,? extends T2> pair)
           
SingletonRelation(T1 first, T2 second)
           
 
Method Summary
 boolean contains(java.lang.Object obj)
          Checks for the given entry in functionMap().
 boolean contains(T1 candidate1, T2 candidate2)
          Checks for the given entry in functionMap().
 PredicateSet<T1> firstSet()
          Returns functionMap().keySet().
 LambdaMap<T1,T2> functionMap()
          A map view of the relation, mapping firsts to seconds.
 boolean hasFixedSize()
          Returns functionMap().keySet().hasFixedSize().
 LambdaMap<T2,T1> injectionMap()
          A map view of the relation, mapping seconds to firsts.
 OneToOneRelation<T2,T1> inverse()
          Returns an AbstractOneToOneRelation.InverseOneToOneRelation.
 boolean isEmpty()
          Returns functionMap().isEmpty().
 boolean isInfinite()
          Returns functionMap().keySet().isInfinite().
 boolean isStatic()
          true if this iterable is unchanging.
 java.util.Iterator<Pair<T1,T2>> iterator()
          Produces an iterator based on functionMap().entrySet().
static
<T1,T2> SingletonRelation<T1,T2>
make(Pair<? extends T1,? extends T2> pair)
          Call the constructor (allows type arguments to be inferred)
static
<T1,T2> SingletonRelation<T1,T2>
make(T1 first, T2 second)
          Call the constructor (allows type arguments to be inferred)
 PredicateSet<T2> matchFirst(T1 match)
          Returns a set that queries and manipulates the mapping from first in functionMap().
 PredicateSet<T1> matchSecond(T2 match)
          Returns a set that queries and manipulates the mapping from second in injectionMap().
 PredicateSet<T2> secondSet()
          Returns injectionMap().keySet().
 int size()
          Returns functionMap().size().
 int size(int bound)
          Returns functionMap().keySet().size(bound).
 
Methods inherited from class edu.rice.cs.plt.collect.AbstractOneToOneRelation
antecedent, containsSecond
 
Methods inherited from class edu.rice.cs.plt.collect.AbstractFunctionalRelation
containsFirst, value
 
Methods inherited from class edu.rice.cs.plt.collect.AbstractRelation
add, add, excludeFirsts, excludeSeconds, remove, remove
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, 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.OneToOneRelation
add, add
 
Methods inherited from interface edu.rice.cs.plt.collect.FunctionalRelation
value
 
Methods inherited from interface edu.rice.cs.plt.collect.Relation
containsFirst, excludeFirsts, excludeSeconds, remove, remove
 
Methods inherited from interface java.util.Set
addAll, clear, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SingletonRelation

public SingletonRelation(T1 first,
                         T2 second)

SingletonRelation

public SingletonRelation(Pair<? extends T1,? extends T2> pair)
Method Detail

isEmpty

public boolean isEmpty()
Description copied from class: AbstractFunctionalRelation
Returns functionMap().isEmpty().

Specified by:
isEmpty in interface SizedIterable<Pair<T1,T2>>
Specified by:
isEmpty in interface java.util.Collection<Pair<T1,T2>>
Specified by:
isEmpty in interface java.util.Set<Pair<T1,T2>>
Overrides:
isEmpty in class AbstractFunctionalRelation<T1,T2>

size

public int size()
Description copied from class: AbstractFunctionalRelation
Returns functionMap().size().

Specified by:
size in interface SizedIterable<Pair<T1,T2>>
Specified by:
size in interface java.util.Collection<Pair<T1,T2>>
Specified by:
size in interface java.util.Set<Pair<T1,T2>>
Overrides:
size in class AbstractFunctionalRelation<T1,T2>

size

public int size(int bound)
Description copied from class: AbstractFunctionalRelation
Returns functionMap().keySet().size(bound).

Specified by:
size in interface SizedIterable<Pair<T1,T2>>
Overrides:
size in class AbstractFunctionalRelation<T1,T2>
Parameters:
bound - Maximum result. Assumed to be nonnegative.

isInfinite

public boolean isInfinite()
Description copied from class: AbstractFunctionalRelation
Returns functionMap().keySet().isInfinite().

Specified by:
isInfinite in interface SizedIterable<Pair<T1,T2>>
Overrides:
isInfinite in class AbstractFunctionalRelation<T1,T2>

hasFixedSize

public boolean hasFixedSize()
Description copied from class: AbstractFunctionalRelation
Returns functionMap().keySet().hasFixedSize().

Specified by:
hasFixedSize in interface SizedIterable<Pair<T1,T2>>
Overrides:
hasFixedSize in class AbstractFunctionalRelation<T1,T2>

isStatic

public 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 AbstractOneToOneRelation<T1,T2>

contains

public boolean contains(T1 candidate1,
                        T2 candidate2)
Description copied from class: AbstractFunctionalRelation
Checks for the given entry in functionMap().

Specified by:
contains in interface Relation<T1,T2>
Specified by:
contains in interface Predicate2<T1,T2>
Overrides:
contains in class AbstractFunctionalRelation<T1,T2>

contains

public boolean contains(java.lang.Object obj)
Description copied from class: AbstractFunctionalRelation
Checks for the given entry in functionMap().

Specified by:
contains in interface Relation<T1,T2>
Specified by:
contains in interface Predicate<java.lang.Object>
Specified by:
contains in interface java.util.Collection<Pair<T1,T2>>
Specified by:
contains in interface java.util.Set<Pair<T1,T2>>
Overrides:
contains in class AbstractFunctionalRelation<T1,T2>

iterator

public java.util.Iterator<Pair<T1,T2>> iterator()
Description copied from class: AbstractFunctionalRelation
Produces an iterator based on functionMap().entrySet().

Specified by:
iterator in interface java.lang.Iterable<Pair<T1,T2>>
Specified by:
iterator in interface java.util.Collection<Pair<T1,T2>>
Specified by:
iterator in interface java.util.Set<Pair<T1,T2>>
Overrides:
iterator in class AbstractFunctionalRelation<T1,T2>

functionMap

public 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 AbstractOneToOneRelation<T1,T2>

injectionMap

public 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>
Specified by:
injectionMap in class AbstractOneToOneRelation<T1,T2>

firstSet

public PredicateSet<T1> firstSet()
Description copied from class: AbstractFunctionalRelation
Returns functionMap().keySet().

Specified by:
firstSet in interface Relation<T1,T2>
Overrides:
firstSet in class AbstractFunctionalRelation<T1,T2>

matchFirst

public PredicateSet<T2> matchFirst(T1 match)
Description copied from class: AbstractFunctionalRelation
Returns a set that queries and manipulates the mapping from first in functionMap().

Specified by:
matchFirst in interface FunctionalRelation<T1,T2>
Specified by:
matchFirst in interface Relation<T1,T2>
Overrides:
matchFirst in class AbstractFunctionalRelation<T1,T2>

secondSet

public PredicateSet<T2> secondSet()
Description copied from class: AbstractOneToOneRelation
Returns injectionMap().keySet().

Specified by:
secondSet in interface Relation<T1,T2>
Overrides:
secondSet in class AbstractOneToOneRelation<T1,T2>

matchSecond

public PredicateSet<T1> matchSecond(T2 match)
Description copied from class: AbstractOneToOneRelation
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>
Overrides:
matchSecond in class AbstractOneToOneRelation<T1,T2>

inverse

public OneToOneRelation<T2,T1> inverse()
Description copied from class: AbstractOneToOneRelation
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 AbstractOneToOneRelation<T1,T2>

make

public static <T1,T2> SingletonRelation<T1,T2> make(T1 first,
                                                    T2 second)
Call the constructor (allows type arguments to be inferred)


make

public static <T1,T2> SingletonRelation<T1,T2> make(Pair<? extends T1,? extends T2> pair)
Call the constructor (allows type arguments to be inferred)