|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.brics.xact.analysis.util.MultiMap<K,V>
K
- key typeV
- value typepublic class MultiMap<K,V>
Maps keys to sets of values.
For practical reasons, this does not implement Map<K, Set<V>>
, although
it is conceptually that type of map.
Constructor Summary | |
---|---|
MultiMap()
|
Method Summary | ||
---|---|---|
boolean |
add(K key,
V value)
Adds a key-value pair to the multimap. |
|
boolean |
addAll(K key,
Collection<? extends V> values)
Adds a key-value pair for each value in the specified set. |
|
void |
clear()
Removes all key-value pairs. |
|
boolean |
contains(K key,
V value)
Determines if the multimap contains the specified key-value pair. |
|
int |
count(K key)
|
|
K |
getAnyKey()
Returns any of the keys in the map, that has at least one associated value. |
|
V |
getAnyValue(K key)
Returns any of the values associated with the specified key, or null if no values are associated with the key. |
|
Set<V> |
getValues(K key)
Returns a copy of the set of items associated with the specified key. |
|
Set<V> |
getView(K key)
Returns a read-only view of the items associated with the specified key. |
|
Set<K> |
keySet()
Returns the set of keys with at least one associated value, backed by the multimap. |
|
int |
numberOfKeys()
|
|
|
putAll(MultiMap<K2,V2> other)
Adds all key-value pairs from the other map to this map. |
|
boolean |
remove(K key,
V value)
Removes a key-value pair from the multimap. |
|
boolean |
removeAll(K key)
Removes all key-value pairs with the specified key. |
|
int |
size()
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MultiMap()
Method Detail |
---|
public boolean add(K key, V value)
public boolean addAll(K key, Collection<? extends V> values)
key
- the key to associate with each of the specified values.values
- the values to associate with the specified key.
public void clear()
public boolean contains(K key, V value)
public int count(K key)
public K getAnyKey()
public V getAnyValue(K key)
public Set<V> getValues(K key)
public Set<V> getView(K key)
In the current implementation, changes always propagate until the specified key has no associated values, at which point all existing views of that key are cleared and disconnected from the multimap.
public Set<K> keySet()
Keys may be removed from the returned set, but attempting to add a key will throw
an UnsupportedOperationException
. Removing a key will disconnect all existing
views of that particular key from the multimap.
public int numberOfKeys()
public <K2 extends K,V2 extends V> boolean putAll(MultiMap<K2,V2> other)
other
- another multi map.
public boolean remove(K key, V value)
key
- value
-
public boolean removeAll(K key)
key
- key to remove from the map.
public int size()
public String toString()
toString
in class Object
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |