edu.rice.cs.plt.collect
Class IndexedOneToOneRelation<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.IndexedOneToOneRelation<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 IndexedOneToOneRelation<T1,T2>
extends AbstractOneToOneRelation<T1,T2>
implements java.io.Serializable

A implementation of OneToOneRelation based on indexing maps.

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
IndexedOneToOneRelation()
          Index using HashMaps.
IndexedOneToOneRelation(Thunk<java.util.Map<T1,T2>> firstIndexFactory, Thunk<java.util.Map<T2,T1>> secondIndexFactory)
          Create an IndexedOneToOneRelation using the given map factories to produce indices.
 
Method Summary
 boolean add(T1 first, T2 second)
          Add Pair.make(first, second) to the set.
 void clear()
           
 LambdaMap<T1,T2> functionMap()
          A map view of the relation, mapping firsts to seconds.
 LambdaMap<T2,T1> injectionMap()
          A map view of the relation, mapping seconds to firsts.
 boolean isStatic()
          true if this iterable is unchanging.
static
<T1,T2> IndexedOneToOneRelation<T1,T2>
makeHashBased()
          Make an IndexedOneToOneRelation indexed by HashMaps.
static
<T1,T2> IndexedOneToOneRelation<T1,T2>
makeLinkedHashBased()
          Make an IndexedOneToOneRelation indexed by LinkedHashMaps.
static
<T1 extends java.lang.Comparable<? super T1>,T2 extends java.lang.Comparable<? super T2>>
IndexedOneToOneRelation<T1,T2>
makeTreeBased()
          Make an IndexedOneToOneRelation indexed by TreeMaps.
 boolean remove(T1 first, T2 second)
          Remove Pair.make(first, second) from the set.
 
Methods inherited from class edu.rice.cs.plt.collect.AbstractOneToOneRelation
antecedent, containsSecond, inverse, matchSecond, secondSet
 
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 class edu.rice.cs.plt.collect.AbstractRelation
add, excludeFirsts, excludeSeconds, remove
 
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 edu.rice.cs.plt.collect.OneToOneRelation
add
 
Methods inherited from interface edu.rice.cs.plt.collect.FunctionalRelation
matchFirst, value
 
Methods inherited from interface edu.rice.cs.plt.collect.Relation
contains, contains, containsFirst, excludeFirsts, excludeSeconds, firstSet, remove
 
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface edu.rice.cs.plt.iter.SizedIterable
hasFixedSize, isEmpty, isInfinite, size, size
 

Constructor Detail

IndexedOneToOneRelation

public IndexedOneToOneRelation()
Index using HashMaps.


IndexedOneToOneRelation

public IndexedOneToOneRelation(Thunk<java.util.Map<T1,T2>> firstIndexFactory,
                               Thunk<java.util.Map<T2,T1>> secondIndexFactory)
Create an IndexedOneToOneRelation using the given map factories to produce indices.

Method Detail

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>

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>

add

public boolean add(T1 first,
                   T2 second)
Description copied from interface: Relation
Add Pair.make(first, second) to the set.

Specified by:
add in interface FunctionalRelation<T1,T2>
Specified by:
add in interface InjectiveRelation<T1,T2>
Specified by:
add in interface OneToOneRelation<T1,T2>
Specified by:
add in interface Relation<T1,T2>
Overrides:
add in class AbstractRelation<T1,T2>

remove

public boolean remove(T1 first,
                      T2 second)
Description copied from interface: Relation
Remove Pair.make(first, second) from the set.

Specified by:
remove in interface Relation<T1,T2>
Overrides:
remove in class AbstractRelation<T1,T2>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<Pair<T1,T2>>
Specified by:
clear in interface java.util.Set<Pair<T1,T2>>
Overrides:
clear in class java.util.AbstractCollection<Pair<T1,T2>>

makeHashBased

public static <T1,T2> IndexedOneToOneRelation<T1,T2> makeHashBased()
Make an IndexedOneToOneRelation indexed by HashMaps.


makeLinkedHashBased

public static <T1,T2> IndexedOneToOneRelation<T1,T2> makeLinkedHashBased()
Make an IndexedOneToOneRelation indexed by LinkedHashMaps.


makeTreeBased

public static <T1 extends java.lang.Comparable<? super T1>,T2 extends java.lang.Comparable<? super T2>> IndexedOneToOneRelation<T1,T2> makeTreeBased()
Make an IndexedOneToOneRelation indexed by TreeMaps.