harpoon.Util.DataStructs
Interface Relation

All Known Implementing Classes:
AbstrRelation, RelationImpl

public interface Relation

Relation is a mathematical relation, accepting one to many and many to one mappings.

It is similar to harpoon.Util.Collections.MultiMap but it is intended to be simpler and better tailored for the implementation of the Pointer Analysis algorithm.

Version:
$Id: Relation.java,v 1.2 2002/02/25 21:09:19 cananian Exp $
Author:
Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu>

Method Summary
 boolean add(Object key, Object value)
          Adds the pair <key, value> to the relation.
 boolean addAll(Object key, Collection values)
          Adds a relation from key to each element of the set values.
 Object clone()
          Clones this relation.
 boolean contains(Object key, Object value)
          Checks the existence of the relation <key,value>.
 boolean containsKey(Object key)
          Checks the existence of the key key in this relation.
 boolean equals(Object o)
          Checks the equality of two relations
 void forAllEntries(RelationEntryVisitor visitor)
          Visits all the entries <key,value> of this relation and calls visitor.visit on each of them.
 Set getValues(Object key)
          Returns the image of key through this relation.
 boolean isEmpty()
          Tests if this relation is empty or not.
 Set keys()
          Returns all the keys appearing in this relation.
 void remove(Object key, Object value)
          Removes the relation between key and value.
 void removeAll(Object key, Collection values)
          Removes the relation between key and any element from values.
 void removeKey(Object key)
          Removes all the relations attached to key.
 void removeKeys(PredicateWrapper predicate)
          Removes all the keys that satisfy predicate.check().
 void removeObjects(PredicateWrapper predicate)
          Removes all the relations involving at least one object that satisfy predicate.check().
 void removeValues(PredicateWrapper predicate)
          Removes all the values that satisfy predicate.check().
 void revert(Relation result)
          Revert this relation and store the result into the relation result.
 Relation select(Collection selected_keys)
          Returns the subrelation of this relation that contains only the keys that appear in selected_keys.
 void union(Relation rel)
          Combines this relation with a new one.
 Set values()
          Returns all the values appearing in this relation.
 

Method Detail

add

public boolean add(Object key,
                   Object value)
Adds the pair <key, value> to the relation. Returns true if the new relation is bigger.


addAll

public boolean addAll(Object key,
                      Collection values)
Adds a relation from key to each element of the set values. values should not contain duplicated elements. Returns true if the new relation is bigger.


remove

public void remove(Object key,
                   Object value)
Removes the relation between key and value.


removeAll

public void removeAll(Object key,
                      Collection values)
Removes the relation between key and any element from values.


removeKey

public void removeKey(Object key)
Removes all the relations attached to key.


removeKeys

public void removeKeys(PredicateWrapper predicate)
Removes all the keys that satisfy predicate.check().


removeValues

public void removeValues(PredicateWrapper predicate)
Removes all the values that satisfy predicate.check().


removeObjects

public void removeObjects(PredicateWrapper predicate)
Removes all the relations involving at least one object that satisfy predicate.check().


contains

public boolean contains(Object key,
                        Object value)
Checks the existence of the relation <key,value>.


containsKey

public boolean containsKey(Object key)
Checks the existence of the key key in this relation.


isEmpty

public boolean isEmpty()
Tests if this relation is empty or not.


getValues

public Set getValues(Object key)
Returns the image of key through this relation. The returned collection is guarranted not to contain duplicates. Can return null if no value is attached to key. If the result is non-null, additions and removals on the returned collection take effect on the relation.


keys

public Set keys()
Returns all the keys appearing in this relation. The result is guaranted not to contain duplicates.


values

public Set values()
Returns all the values appearing in this relation.


union

public void union(Relation rel)
Combines this relation with a new one. A null parameter is considered to be an empty relation.


equals

public boolean equals(Object o)
Checks the equality of two relations

Overrides:
equals in class Object

select

public Relation select(Collection selected_keys)
Returns the subrelation of this relation that contains only the keys that appear in selected_keys.


forAllEntries

public void forAllEntries(RelationEntryVisitor visitor)
Visits all the entries <key,value> of this relation and calls visitor.visit on each of them.


clone

public Object clone()
Clones this relation.

Overrides:
clone in class Object

revert

public void revert(Relation result)
Revert this relation and store the result into the relation result. <a,b> appears in the reverse relation iff <b,a> appears in this relation.