|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> java.util.TreeMap<X,java.util.Set<Y>> org.knowceans.map.TreeMultiMap<X,Y> org.knowceans.map.InvertibleTreeMultiMap<X,Y>
public class InvertibleTreeMultiMap<X,Y>
This object maps each key to a Set of values and holds each member of this Set as a link to a Set of keys, i.e., depicts a IMultiMap (object -> set) with an inverse IMultiMap. With getInverse(), the (forward) key set can easily be found from the (forward) value. This effectively implements an M to N relation.
In relational terms, this class implements an m:n relation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Constructor Summary | |
---|---|
InvertibleTreeMultiMap()
|
|
InvertibleTreeMultiMap(java.util.Comparator<? super X> c)
|
|
InvertibleTreeMultiMap(java.util.Map m)
|
|
InvertibleTreeMultiMap(java.util.Map m,
HashMultiMap<Y,X> inverse)
|
Method Summary | |
---|---|
void |
add(X key,
Y value)
adds the value to the key's value set and the key to the value's key set. |
void |
clear()
|
IMultiMap<Y,X> |
getInverse()
returns the hash map of the inverse (not that this is not a tree map). |
java.util.Set<X> |
getInverse(java.util.Set<Y> value)
returns the keys that match a given set of value elements |
java.util.Set<X> |
getInverseValue(Y val)
gets keys for a value as a Set. |
static void |
main(java.lang.String[] args)
some simple tests and demonstration for HashMultiMap |
java.util.Set<Y> |
put(X key,
java.util.Set<Y> valSet)
put a new key-valueSet pair. |
java.util.Set<Y> |
remove(java.lang.Object key)
removes the (forward) key and its elements from it value set from the map that map to key. |
void |
remove(X key,
Y value)
removes the value from the key's mapping. |
Methods inherited from class java.util.TreeMap |
---|
ceilingEntry, ceilingKey, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, size, subMap, subMap, tailMap, tailMap, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, isEmpty, toString |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, size, values |
Constructor Detail |
---|
public InvertibleTreeMultiMap()
public InvertibleTreeMultiMap(java.util.Comparator<? super X> c)
c
- public InvertibleTreeMultiMap(java.util.Map m)
m
- public InvertibleTreeMultiMap(java.util.Map m, HashMultiMap<Y,X> inverse)
inverse
- allow to set an inverse map that could be a tree map with
its own comparator.m
- Method Detail |
---|
public static void main(java.lang.String[] args)
args
- public void clear()
clear
in interface java.util.Map<X,java.util.Set<Y>>
clear
in class java.util.TreeMap<X,java.util.Set<Y>>
public void add(X key, Y value)
add
in interface IMultiMap<X,Y>
add
in class TreeMultiMap<X,Y>
key
- The key of the new entry.value
- The value of the new entry.public java.util.Set<Y> put(X key, java.util.Set<Y> valSet)
put
in interface java.util.Map<X,java.util.Set<Y>>
put
in class TreeMultiMap<X,Y>
public java.util.Set<Y> remove(java.lang.Object key)
remove
in interface java.util.Map<X,java.util.Set<Y>>
remove
in class java.util.TreeMap<X,java.util.Set<Y>>
public void remove(X key, Y value)
remove
in interface IMultiMap<X,Y>
remove
in class TreeMultiMap<X,Y>
key
- The key of the new entry.value
- The value of the new entry.public java.util.Set<X> getInverseValue(Y val)
val
-
public java.util.Set<X> getInverse(java.util.Set<Y> value)
value
-
public IMultiMap<Y,X> getInverse()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |