|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap
common.HashMultiMap
public class HashMultiMap
Implementation of the MultiMap interface that uses a HashMap for the map and HashSets for automatically created sets.
Technically, a MultiMap implementation should put a wrapper around
the iterators for the underlying data structure so the values associated
with keys are unmodifiable sets. Also, its Map.Entry objects
should have a setValue method that removes the key when the
value is set to an empty set. For now, we don't bother with these issues.
| Nested Class Summary | |
|---|---|
protected class |
HashMultiMap.ValueSet
|
| 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 common.MultiMap |
|---|
MultiMap.EmptyMultiMap |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected boolean |
maintainOrder
|
protected java.util.HashMap |
map
|
| Fields inherited from interface common.MultiMap |
|---|
EMPTY_MULTI_MAP |
| Constructor Summary | |
|---|---|
HashMultiMap()
Creates a new, empty HashMultiMap. |
|
HashMultiMap(boolean maintainOrder)
Creates a new, empty HashMultiMap. |
|
HashMultiMap(MultiMap orig)
Creates a new HashMultiMap that is equal to the given MultiMap. |
|
| Method Summary | |
|---|---|
boolean |
add(java.lang.Object key,
java.lang.Object value)
Adds the given value to the set associated with the given key. |
boolean |
addAll(java.lang.Object key,
java.util.Set values)
Adds all elements of the given set to the set associated with the given key. |
void |
clear()
|
java.lang.Object |
clone()
Returns a shallow copy of this multi-map. |
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
protected java.util.Set |
copySet(java.util.Set orig)
|
protected java.util.Set |
emptySet()
|
java.util.Set |
entrySet()
|
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
get(java.lang.Object key)
Returns the set associated with the given key. |
int |
hashCode()
|
java.util.Set |
keySet()
|
protected java.util.Set |
newSet()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the given key with the given value, which must be a Set. |
java.lang.Object |
remove(java.lang.Object key)
|
boolean |
remove(java.lang.Object key,
java.lang.Object value)
Removes the given value from the set associated with the given key. |
boolean |
removeAll(java.lang.Object key,
java.util.Set values)
Removes all elements of the given set from the set associated with the given key. |
int |
size()
|
| Methods inherited from class java.util.AbstractMap |
|---|
isEmpty, putAll, toString, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
isEmpty, putAll, values |
| Field Detail |
|---|
protected java.util.HashMap map
protected boolean maintainOrder
| Constructor Detail |
|---|
public HashMultiMap()
public HashMultiMap(boolean maintainOrder)
maintainOrder
is true, then this instance uses a LinkedHashMap and LinkedHashSets
so that the iteration orders for keys, and for elements of value
sets, are predictable.
public HashMultiMap(MultiMap orig)
| Method Detail |
|---|
public int size()
size in interface java.util.Mapsize in class java.util.AbstractMappublic boolean containsKey(java.lang.Object key)
containsKey in interface java.util.MapcontainsKey in class java.util.AbstractMappublic boolean containsValue(java.lang.Object value)
containsValue in interface java.util.MapcontainsValue in class java.util.AbstractMappublic java.lang.Object get(java.lang.Object key)
MultiMapput method is called or if all the values for the
given key are removed.
get in interface MultiMapget in interface java.util.Mapget in class java.util.AbstractMap
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
MultiMap
put in interface MultiMapput in interface java.util.Mapput in class java.util.AbstractMap
public boolean add(java.lang.Object key,
java.lang.Object value)
MultiMap
add in interface MultiMap
public boolean addAll(java.lang.Object key,
java.util.Set values)
MultiMap
addAll in interface MultiMappublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mapremove in class java.util.AbstractMap
public boolean remove(java.lang.Object key,
java.lang.Object value)
MultiMap
remove in interface MultiMap
public boolean removeAll(java.lang.Object key,
java.util.Set values)
MultiMap
removeAll in interface MultiMappublic void clear()
clear in interface java.util.Mapclear in class java.util.AbstractMappublic java.util.Set entrySet()
entrySet in interface java.util.MapentrySet in class java.util.AbstractMappublic java.util.Set keySet()
keySet in interface java.util.MapkeySet in class java.util.AbstractMappublic boolean equals(java.lang.Object o)
equals in interface java.util.Mapequals in class java.util.AbstractMappublic int hashCode()
hashCode in interface java.util.MaphashCode in class java.util.AbstractMappublic java.lang.Object clone()
clone in class java.util.AbstractMapprotected java.util.Set emptySet()
protected java.util.Set newSet()
protected java.util.Set copySet(java.util.Set orig)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||