|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.stanford.nlp.util.CollectionValuedMap<K,V>
K - Key type of mapV - Type of the Collection that is the Map's valuepublic class CollectionValuedMap<K,V>
Map from keys to Collections. Important methods are the add(K, V)
and remove(java.lang.Object) methods for adding and removing a value to/from the
Collection associated with the key, and the get(java.lang.Object) method for getting
the Collection associated with a key. The class is quite general, because on
construction, it is possible to pass a MapFactory which will be used
to create the underlying map and a CollectionFactory which will be
used to create the Collections. Thus this class can be configured to act like
a "HashSetValuedMap" or a "ListValuedMap", or even a
"HashSetValuedIdentityHashMap". The possibilities are endless!
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected CollectionFactory<V> |
cf
|
protected MapFactory<K,java.util.Collection<V>> |
mf
|
| Constructor Summary | |
|---|---|
CollectionValuedMap()
Creates a new empty CollectionValuedMap which uses a HashMap as the underlying Map, and HashSets as the Collections in each mapping. |
|
CollectionValuedMap(CollectionFactory<V> cf)
Creates a new empty CollectionValuedMap which uses a HashMap as the underlying Map. |
|
CollectionValuedMap(CollectionValuedMap<K,V> cvm)
Creates a new CollectionValuedMap with all of the mappings from cvm. |
|
CollectionValuedMap(MapFactory<K,java.util.Collection<V>> mf,
CollectionFactory<V> cf,
boolean treatCollectionsAsImmutable)
Creates a new empty CollectionValuedMap. |
|
| Method Summary | |
|---|---|
void |
add(K key,
V value)
Adds the value to the Collection mapped to by the key. |
void |
addAll(CollectionValuedMap<K,V> cvm)
|
void |
addAll(java.util.Map<K,V> m)
Adds all of the mappings in m to this CollectionValuedMap. |
java.util.Collection<V> |
allValues()
|
void |
clear()
Clears this Map. |
CollectionValuedMap<K,V> |
clone()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
Unsupported. |
CollectionValuedMap<K,V> |
deltaClone()
Creates a "delta clone" of this Map, where only the differences are represented. |
java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> |
entrySet()
Each element of the Set is a Map.Entry object, where getKey() returns the key of the mapping, and getValue() returns the Collection mapped to by the key. |
boolean |
equals(java.lang.Object o)
|
java.util.Collection<V> |
get(java.lang.Object key)
|
int |
hashCode()
|
boolean |
isEmpty()
|
java.util.Set<K> |
keySet()
|
static void |
main(java.lang.String[] args)
For testing only. |
java.util.Collection<V> |
put(K key,
java.util.Collection<V> collection)
Replaces current Collection mapped to key with the specified Collection. |
void |
putAll(java.util.Map<? extends K,? extends java.util.Collection<V>> m)
Unsupported. |
java.util.Collection<V> |
remove(java.lang.Object key)
Removes the mapping associated with this key from this Map. |
void |
removeAll(java.util.Collection<K> keys)
removes the mappings associated with the keys from this map |
void |
removeMapping(K key,
V value)
Removes the value from the Collection mapped to by this key, leaving the rest of the collection intact. |
int |
size()
The number of keys in this map. |
java.lang.String |
toString()
|
java.util.Collection<java.util.Collection<V>> |
values()
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected CollectionFactory<V> cf
protected MapFactory<K,java.util.Collection<V>> mf
| Constructor Detail |
|---|
public CollectionValuedMap(MapFactory<K,java.util.Collection<V>> mf,
CollectionFactory<V> cf,
boolean treatCollectionsAsImmutable)
mf - a MapFactory which will be used to generate the underlying Mapcf - a CollectionFactory which will be used to generate the Collections
in each mappingtreatCollectionsAsImmutable - if true, forces this Map to create new a Collection everytime a
new value is added to or deleted from the Collection a mapping.public CollectionValuedMap(CollectionValuedMap<K,V> cvm)
clone().
public CollectionValuedMap()
public CollectionValuedMap(CollectionFactory<V> cf)
cf - a CollectionFactory which will be used to generate the Collections
in each mapping| Method Detail |
|---|
public java.util.Collection<V> put(K key,
java.util.Collection<V> collection)
put in interface java.util.Map<K,java.util.Collection<V>>public void putAll(java.util.Map<? extends K,? extends java.util.Collection<V>> m)
addAll(Map) instead.
putAll in interface java.util.Map<K,java.util.Collection<V>>public java.util.Collection<V> get(java.lang.Object key)
get in interface java.util.Map<K,java.util.Collection<V>>
public void add(K key,
V value)
public void addAll(java.util.Map<K,V> m)
public void addAll(CollectionValuedMap<K,V> cvm)
public java.util.Collection<V> remove(java.lang.Object key)
remove in interface java.util.Map<K,java.util.Collection<V>>public void removeAll(java.util.Collection<K> keys)
keys -
public void removeMapping(K key,
V value)
key - the key to the Collection to remove the value fromvalue - the value to removepublic void clear()
clear in interface java.util.Map<K,java.util.Collection<V>>public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<K,java.util.Collection<V>>public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<K,java.util.Collection<V>>public boolean isEmpty()
isEmpty in interface java.util.Map<K,java.util.Collection<V>>public java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> entrySet()
entrySet in interface java.util.Map<K,java.util.Collection<V>>public java.util.Set<K> keySet()
keySet in interface java.util.Map<K,java.util.Collection<V>>public int size()
size in interface java.util.Map<K,java.util.Collection<V>>public java.util.Collection<java.util.Collection<V>> values()
values in interface java.util.Map<K,java.util.Collection<V>>public java.util.Collection<V> allValues()
public boolean equals(java.lang.Object o)
equals in interface java.util.Map<K,java.util.Collection<V>>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Map<K,java.util.Collection<V>>hashCode in class java.lang.Objectpublic CollectionValuedMap<K,V> deltaClone()
public CollectionValuedMap<K,V> clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] args)
args - from command line
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||