public class ManyToMany<T1,T2>
extends java.lang.Object
The map permits the null value for keys nor for value elements.
Design invariants preserved by all operations on this map are as follows:
| Constructor and Description |
|---|
ManyToMany() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
clear()
Empty all maps.
|
void |
clearDirtyBit()
Sets the dirty bit to false.
|
boolean |
containsKey(T1 key)
Equivalent to keySet().contains(key).
|
boolean |
containsKeyValuePair(T1 key,
T2 value)
Is there a key that is mapped to the specified value?
Search within the forward map.
|
boolean |
containsValue(T2 value)
Equivalent to values().contains(value).
|
java.util.Set<T1> |
getKeys(T2 value)
Search the reverse map for all keys that have been associated with
a particular value.
|
java.util.Set<T1> |
getKeySet() |
java.util.Set<T2> |
getValues(T1 key)
Search the forward map for all values associated with a particular key.
|
java.util.Set<T2> |
getValueSet() |
boolean |
isDirty()
Return the state of the dirty bit.
|
boolean |
keyHasOtherValues(T1 key,
T2 value)
Check whether
key has an association to any values other
than value - that is, whether the same key has been added
with multiple values. |
boolean |
put(T1 key,
T2 value)
Associate the specified value with the key.
|
boolean |
remove(T1 key,
T2 value)
Remove a particular key-value association.
|
boolean |
removeKey(T1 key)
Remove the key and its associated key/value entries.
|
boolean |
removeValue(T2 value)
Remove the value and its associated key/value entries.
|
boolean |
valueHasOtherKeys(T2 value,
T1 key)
Check whether
value has an association from any keys other
than key - that is, whether the same value has been added
with multiple keys. |
public boolean clear()
public void clearDirtyBit()
public boolean containsKey(T1 key)
public boolean containsKeyValuePair(T1 key, T2 value)
public boolean containsValue(T2 value)
public java.util.Set<T1> getKeys(T2 value)
public java.util.Set<T2> getValues(T1 key)
public java.util.Set<T1> getKeySet()
getValueSet()public java.util.Set<T2> getValueSet()
getKeySet()public boolean isDirty()
clearDirtyBit()public boolean keyHasOtherValues(T1 key, T2 value)
key has an association to any values other
than value - that is, whether the same key has been added
with multiple values. Equivalent to asking whether the intersection of
getValues(key) and the set containing value is
non-empty.key is in the map and is associated
with values other than value.valueHasOtherKeys(Object, Object)public boolean put(T1 key, T2 value)
key - can be nullvalue - can be nullpublic boolean remove(T1 key, T2 value)
public boolean removeKey(T1 key)
public boolean removeValue(T2 value)
public boolean valueHasOtherKeys(T2 value, T1 key)
value has an association from any keys other
than key - that is, whether the same value has been added
with multiple keys. Equivalent to asking whether the intersection of
getKeys(value) and the set containing key is
non-empty.value is in the map and is associated
with keys other than key.keyHasOtherValues(Object, Object)