|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpl.edu.agh.cast.common.collections.MultiMap<K,V>
K - key typeV - value typepublic class MultiMap<K,V>
This class implements a multi-map functionality. Multi-map is a map which allows for multiple values to be kept under
one key.
This implementation (by default) uses HashMap with LinkedLists, however different Map
implementation may be provided during construction.
WARNING: This collection does not implement Collection interface and is not in the Java Collections
hierarchy.
| Constructor Summary | |
|---|---|
MultiMap()
Creates new instance using HashMap as underlying map. |
|
MultiMap(boolean allowDuplicates)
Creates new instance using HashMap as underlying map. |
|
MultiMap(Map<K,List<V>> map)
Creates new instance using map as underlying map. |
|
MultiMap(Map<K,List<V>> map,
boolean allowDuplicates)
Creates new instance using map as underlying map. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object obj)
|
List<V> |
get(K key)
Returns a (modifiable) list of values stored under given key. |
Map<K,List<V>> |
getMap()
Returns an unmodifiable view of the underlying map. |
int |
hashCode()
|
boolean |
isAllowDuplicates()
Checks if duplicate values are allowed for one key. |
List<V> |
put(K key,
V... values)
Adds values to the key entry. |
List<V> |
putAll(K key,
Collection<V> values)
Adds a collection of values to the key entry. |
List<V> |
remove(K key,
V value)
Removes a value for given key. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MultiMap()
HashMap as underlying map. No duplicate values for single key are allowed.
public MultiMap(boolean allowDuplicates)
HashMap as underlying map. Duplicate values for single key are allowed if
allowDuplicates is true.
allowDuplicates - if true than duplicate values are allowed for one key. Defaults to falsepublic MultiMap(Map<K,List<V>> map)
map as underlying map. No duplicate values for single key are allowed.
map - the underlying map
public MultiMap(Map<K,List<V>> map,
boolean allowDuplicates)
map as underlying map. Duplicate values for single key are allowed if
allowDuplicates is true.
map - the underlying mapallowDuplicates - if true than duplicate values are allowed for one key. Defaults to false| Method Detail |
|---|
public Map<K,List<V>> getMap()
public List<V> put(K key,
V... values)
values to the key entry. Behavior may differ depending on the
isAllowDuplicates() value.
key - the keyvalues - the values to add
public List<V> putAll(K key,
Collection<V> values)
values to the key entry. Behavior may differ depending on the
isAllowDuplicates() value.
key - the keyvalues - the collection of values to add
public List<V> get(K key)
key - the key
public List<V> remove(K key,
V value)
key - the keyvalue - the value to remove
null if there are no more values for the keypublic boolean isAllowDuplicates()
public boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public int hashCode()
hashCode in class ObjectObject.hashCode()public String toString()
toString in class ObjectObject.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||