ral.util
Class SimpleHashRel<FROM,TO>

java.lang.Object
  extended by ral.util.SimpleHashRel<FROM,TO>
All Implemented Interfaces:
MultiRelationship<FROM,TO,FixedPair<FROM,TO>>, SimpleRelationship<FROM,TO>, UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>
Direct Known Subclasses:
SimpleReflexiveHashRel

public class SimpleHashRel<FROM,TO>
extends java.lang.Object
implements SimpleRelationship<FROM,TO>


Constructor Summary
SimpleHashRel()
           
SimpleHashRel(java.util.Collection<? extends Pair<FROM,TO>> r)
           
 
Method Summary
 boolean add(FixedPair<FROM,TO> a)
          Adds a pair to the relationship.
 boolean add(FROM f, TO t)
           
 void clearFrom(FROM f)
          Clears all pairs with t in the TO position
 void clearTo(TO t)
          Clears all pairs with t in the TO position
 void copyFrom(FROM f, FROM t)
          Copies all pairs with f in the FROM position, where the new pairs have t in the FROM position instead.
 void copyTo(TO f, TO t)
          Copies all pairs with f in the TO position, where the new pairs have t in the TO position instead.
 ral.internal.ImmutableHashSetAdaptor<TO> from(FROM f)
          Returns all objects t, such that there exists a pair
 java.util.HashSet<FixedPair<FROM,TO>> fromPairs(FROM f)
          Returns all pairs with f in the FROM position
 FixedPair<FROM,TO> get(FROM f, TO t)
          Gets a Pair instance.
 boolean remove(FROM f, TO t)
          Removes a pair instance
 boolean remove(Pair<FROM,TO> p)
          Removes a pair instance
 ral.internal.ImmutableHashSetAdaptor<FROM> to(TO t)
          Returns all objects f, such that there exists a pair
 java.util.HashSet<FixedPair<FROM,TO>> toPairs(TO t)
          Returns all pairs with t in the TO position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleHashRel

public SimpleHashRel()

SimpleHashRel

public SimpleHashRel(java.util.Collection<? extends Pair<FROM,TO>> r)
Method Detail

add

public boolean add(FixedPair<FROM,TO> a)
Description copied from interface: UniMultiRelationship
Adds a pair to the relationship.

Specified by:
add in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

get

public FixedPair<FROM,TO> get(FROM f,
                              TO t)
Description copied from interface: UniMultiRelationship
Gets a Pair instance.

Specified by:
get in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

add

public boolean add(FROM f,
                   TO t)
Specified by:
add in interface SimpleRelationship<FROM,TO>

clearFrom

public void clearFrom(FROM f)
Description copied from interface: UniMultiRelationship
Clears all pairs with t in the TO position

Specified by:
clearFrom in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

clearTo

public void clearTo(TO t)
Description copied from interface: MultiRelationship
Clears all pairs with t in the TO position

Specified by:
clearTo in interface MultiRelationship<FROM,TO,FixedPair<FROM,TO>>

copyFrom

public void copyFrom(FROM f,
                     FROM t)
Description copied from interface: UniMultiRelationship
Copies all pairs with f in the FROM position, where the new pairs have t in the FROM position instead. Note, this operation clones the underlying Pair instances.

Specified by:
copyFrom in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

copyTo

public void copyTo(TO f,
                   TO t)
Description copied from interface: MultiRelationship
Copies all pairs with f in the TO position, where the new pairs have t in the TO position instead. Note, this operation clones the underlying Pair instances.

Specified by:
copyTo in interface MultiRelationship<FROM,TO,FixedPair<FROM,TO>>

remove

public boolean remove(Pair<FROM,TO> p)
Description copied from interface: UniMultiRelationship
Removes a pair instance

Specified by:
remove in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

remove

public boolean remove(FROM f,
                      TO t)
Description copied from interface: UniMultiRelationship
Removes a pair instance

Specified by:
remove in interface SimpleRelationship<FROM,TO>
Specified by:
remove in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

toPairs

public java.util.HashSet<FixedPair<FROM,TO>> toPairs(TO t)
Description copied from interface: MultiRelationship
Returns all pairs with t in the TO position

Specified by:
toPairs in interface MultiRelationship<FROM,TO,FixedPair<FROM,TO>>

fromPairs

public java.util.HashSet<FixedPair<FROM,TO>> fromPairs(FROM f)
Description copied from interface: UniMultiRelationship
Returns all pairs with f in the FROM position

Specified by:
fromPairs in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>

to

public ral.internal.ImmutableHashSetAdaptor<FROM> to(TO t)
Description copied from interface: MultiRelationship
Returns all objects f, such that there exists a pair

Specified by:
to in interface MultiRelationship<FROM,TO,FixedPair<FROM,TO>>
Specified by:
to in interface SimpleRelationship<FROM,TO>

from

public ral.internal.ImmutableHashSetAdaptor<TO> from(FROM f)
Description copied from interface: UniMultiRelationship
Returns all objects t, such that there exists a pair

Specified by:
from in interface SimpleRelationship<FROM,TO>
Specified by:
from in interface UniMultiRelationship<FROM,TO,FixedPair<FROM,TO>>