| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjpaul.DataStructs.Relation<K,V>
jpaul.DataStructs.MapSetRelation<K,V>
public class MapSetRelation<K,V>
MapSetRelation is an implementation of the
 Relation interface based on a Map from
 keys to Sets of values.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class jpaul.DataStructs.Relation | 
|---|
| Relation.EntryVisitor<Key,Value> | 
| Constructor Summary | |
|---|---|
| MapSetRelation()Constructs a Relationrepresented using aLinkedHashMapfrom keys toLinkedHashSets of values. | |
| MapSetRelation(MapFactory<K,java.util.Set<V>> mapFact,
               SetFactory<V> setFact)Constructs a Relationrepresented by aMapfrom keys toSets of values. | |
| Method Summary | |
|---|---|
| protected  java.util.Set<V> | _getValues(K key) | 
|  boolean | add(K key,
    V value)Adds the pair <key, value>to the relation. | 
|  boolean | addAll(K key,
       java.util.Collection<V> values)Adds a relation from keyto each element of the setvalues. | 
|  java.lang.Object | clone()Creates a new, independent relation (independent = the operations on the new relation won't affect the old one). | 
|  boolean | contains(K key,
         V value)Checks the existence of the relation <key,value>. | 
|  boolean | containsKey(K key)Checks the existence of the keykey in this relation. | 
|  boolean | equals(java.lang.Object o)Checks the equality of two relations | 
|  int | hashCode()Complexity: linear in the number of (key,value) pairs from the relation. | 
|  boolean | isEmpty()Tests if this relation is empty or not. | 
|  java.util.Set<K> | keys()Returns all the keys appearing in thisrelation. | 
|  boolean | remove(K key,
       V value)Removes the relation between keyandvalue. | 
|  boolean | removeAll(K key,
          java.util.Collection<V> values)Removes the relation between keyand 
        any element fromvalues. | 
|  boolean | removeKey(K key)Removes all the relations attached to key. | 
|  boolean | removeKeys(Predicate<K> predicate)Removes all the keys that satisfy predicate.check(). | 
|  boolean | removeValues(Predicate<V> predicate)Removes all the values that satisfy predicate.check(). | 
|  boolean | union(Relation<K,V> rel)Combines thisrelation with relationrel. | 
|  java.lang.Iterable<V> | values()Returns an immutable view of all the values appearing in thisrelation. | 
| Methods inherited from class jpaul.DataStructs.Relation | 
|---|
| containsAll, forAllEntries, getValues, revert, toString, unmodifiableRelation | 
| Methods inherited from class java.lang.Object | 
|---|
| finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public MapSetRelation()
Relation represented using a
        LinkedHashMap from keys to
        LinkedHashSets of values.  Consumes a lot of
        memory but fast for large relation.
public MapSetRelation(MapFactory<K,java.util.Set<V>> mapFact,
                      SetFactory<V> setFact)
Relation represented by a
        Map from keys to Sets of values.
        The map is created by mapFact and the sets by
        setFact.
MapFacts, 
SetFacts| Method Detail | 
|---|
public boolean add(K key,
                   V value)
Relation<key, value> to the relation.
        Returns true if the new relation is bigger.
add in class Relation<K,V>
public boolean addAll(K key,
                      java.util.Collection<V> values)
Relationkey to each element of the set
        values. values should not contain
        duplicated elements.
        Returns true if the new relation is bigger.
addAll in class Relation<K,V>
public boolean remove(K key,
                      V value)
Relationkey and 
        value.
remove in class Relation<K,V>true iff the relation changed
public boolean removeAll(K key,
                         java.util.Collection<V> values)
Relationkey and 
        any element from values.
removeAll in class Relation<K,V>true iff the relation changedpublic boolean removeKey(K key)
Relationkey.
removeKey in class Relation<K,V>true iff the relation changedpublic boolean removeKeys(Predicate<K> predicate)
Relationpredicate.check().
removeKeys in class Relation<K,V>true iff the relation changedpublic boolean removeValues(Predicate<V> predicate)
Relationpredicate.check().
removeValues in class Relation<K,V>true iff the relation changed
public boolean contains(K key,
                        V value)
Relation<key,value>.
contains in class Relation<K,V>public boolean containsKey(K key)
Relationkey key in this relation.
containsKey in class Relation<K,V>public boolean isEmpty()
Relation
isEmpty in class Relation<K,V>protected final java.util.Set<V> _getValues(K key)
_getValues in class Relation<K,V>public java.util.Set<K> keys()
Relationthis relation.
keys in class Relation<K,V>public java.lang.Iterable<V> values()
Relationthis relation.  The view may contain the
        same value twice.
values in class Relation<K,V>public boolean union(Relation<K,V> rel)
Relationthis relation with relation
        rel.  A null parameter is considered
        to be an empty relation.
union in class Relation<K,V>true iff this relation has
        changed.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
Relation
equals in class Relation<K,V>public java.lang.Object clone()
clone in class Relation<K,V>| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||