com.springsource.util.math
Class ConcurrentMapRelation<X,Y>

java.lang.Object
  extended by com.springsource.util.math.ConcurrentMapRelation<X,Y>
All Implemented Interfaces:
ConcurrentRelation<X,Y>

public final class ConcurrentMapRelation<X,Y>
extends java.lang.Object
implements ConcurrentRelation<X,Y>


Field Summary
private  java.util.concurrent.ConcurrentMap<X,ConcurrentSet<Y>> rel
           
 
Constructor Summary
ConcurrentMapRelation()
           
 
Method Summary
 boolean add(X x, Y y)
          Add the given pair (x, y) to the relation.
 boolean contains(X x, Y y)
          Return true if and only if the given pair (x, y) is present in the relation.
 java.util.Set<X> dom()
          Return the domain of the relation.
 void domSubtract(java.util.Set<X> xset)
          Remove all the pairs (x, y) where x is in the given set of X's.
private  void ensure(X x)
           
 java.util.Set<Y> ran()
          The result is potentially blurred in the presence of concurrency.
 java.util.Set<Y> relationalImage(java.util.Set<X> xset)
          Return the relational image of a set of X's.
 boolean remove(X x, Y y)
          Remove the given pair (x, y) from the relation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rel

private final java.util.concurrent.ConcurrentMap<X,ConcurrentSet<Y>> rel
Constructor Detail

ConcurrentMapRelation

public ConcurrentMapRelation()
Method Detail

add

public boolean add(X x,
                   Y y)
Description copied from interface: ConcurrentRelation
Add the given pair (x, y) to the relation. It is not an error if the pair is already present.

Specified by:
add in interface ConcurrentRelation<X,Y>
Returns:
true if and only if the relation was updated

contains

public boolean contains(X x,
                        Y y)
Description copied from interface: ConcurrentRelation
Return true if and only if the given pair (x, y) is present in the relation.

Specified by:
contains in interface ConcurrentRelation<X,Y>
Returns:
true if the pair is present in the relation

dom

public java.util.Set<X> dom()
Description copied from interface: ConcurrentRelation
Return the domain of the relation.

Specified by:
dom in interface ConcurrentRelation<X,Y>
Returns:
a set comprising the domain

ran

public java.util.Set<Y> ran()
The result is potentially blurred in the presence of concurrency.

Specified by:
ran in interface ConcurrentRelation<X,Y>
Returns:
a set comprising the range

remove

public boolean remove(X x,
                      Y y)
Description copied from interface: ConcurrentRelation
Remove the given pair (x, y) from the relation. It is not an error if the pair is not present.

Specified by:
remove in interface ConcurrentRelation<X,Y>
Returns:
true if and only if the relation was updated

ensure

private void ensure(X x)

relationalImage

public java.util.Set<Y> relationalImage(java.util.Set<X> xset)
Description copied from interface: ConcurrentRelation
Return the relational image of a set of X's.

Specified by:
relationalImage in interface ConcurrentRelation<X,Y>
Parameters:
xset - a set of X's
Returns:
the set of Y's which relate to X's in xset

domSubtract

public void domSubtract(java.util.Set<X> xset)
Description copied from interface: ConcurrentRelation
Remove all the pairs (x, y) where x is in the given set of X's.

Specified by:
domSubtract in interface ConcurrentRelation<X,Y>
Parameters:
xset - a set of X's