Modifier and Type | Class and Description |
---|---|
static class |
OneToManyMap.Entry<From,To>
Helper class to implement the Map.Entry interface to enumerate entries in the map
|
Constructor and Description |
---|
OneToManyMap()
Construct a new empty one-to-many map
|
OneToManyMap(OneToManyMap<From,To> map)
Construct a new one-to-many map whose contents are
initialised from the existing map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all entries from the map.
|
boolean |
contains(Object key,
Object value)
Answer true if this mapping contains the pair
(key, value) . |
boolean |
containsKey(Object key)
Answer true if the map contains the given value as a key.
|
boolean |
containsValue(Object value)
Answer true if the map contains the given object as a value
stored against any key.
|
Set<Map.Entry<From,To>> |
entrySet()
Answer a set of the mappings in this map.
|
boolean |
equals(Object o)
Compares the specified object with this map for equality.
|
To |
get(Object key)
Get a value for this key.
|
Iterator<To> |
getAll(Object key)
Answer an iterator over all of the values for the given key.
|
int |
hashCode()
Returns the hash code value for this map.
|
boolean |
isEmpty()
Answer true if the map is empty of key-value mappings.
|
Set<From> |
keySet()
Answer a set of the keys in this map
|
To |
put(From key,
To value)
Associates the given value with the given key.
|
void |
putAll(Map<? extends From,? extends To> m)
Put all entries from one map into this map.
|
To |
remove(Object key)
Remove all of the associations for the given key.
|
boolean |
remove(Object key,
Object value)
Remove the specific association between the given key and value.
|
int |
size()
Answer the number of key-value mappings in the map
|
String |
toString()
Answer a string representation of this map.
|
Collection<To> |
values()
Returns a collection view of the values contained in this map.
|
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, replace, replace, replaceAll
public OneToManyMap()
Construct a new empty one-to-many map
public OneToManyMap(OneToManyMap<From,To> map)
Construct a new one-to-many map whose contents are initialised from the existing map.
map
- An existing one-to-many mappublic void clear()
public boolean containsKey(Object key)
containsKey
in interface Map<From,To>
key
- The key object to test forpublic boolean containsValue(Object value)
containsValue
in interface Map<From,To>
value
- The value to test forpublic boolean contains(Object key, Object value)
Answer true if this mapping contains the pair
(key, value)
.
key
- A key objectvalue
- A value objectkey
has value
as one of its values in this mappingpublic Set<Map.Entry<From,To>> entrySet()
public boolean equals(Object o)
public To get(Object key)
get
in interface Map<From,To>
key
- The key to access the map.getAll(java.lang.Object)
public Iterator<To> getAll(Object key)
key
- The key objectpublic int hashCode()
public boolean isEmpty()
public To put(From key, To value)
public void putAll(Map<? extends From,? extends To> m)
Put all entries from one map into this map. Tests for m being a OneToManyMap, and, if so, copies all of the entries for each key.
public To remove(Object key)
remove( java.lang.Object, java.lang.Object )
instead. Has no effect if the key is not present in the map. Since no
single specific association with the key is defined, this method always
returns null.public boolean remove(Object key, Object value)
Remove the specific association between the given key and value. Has no effect if the association is not present in the map. If all values for a particular key have been removed post removing this particular association, the key will no longer appear as a key in the map.
public int size()
Answer the number of key-value mappings in the map
public Collection<To> values()
Returns a collection view of the values contained in this map. Specifically, this will be a set, so duplicate values that appear for multiple keys are suppressed.
Licenced under the Apache License, Version 2.0