Constructor and Description |
---|
MultiMap()
Constructs a new
MultiMap . |
MultiMap(int capacity)
Constructs a new
MultiMap with the specified initial capacity. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from this map.
|
boolean |
contains(A key,
B value)
Returns true if the multimap contains a value for a key.
|
boolean |
containsKey(A key)
Returns
true if this map contains a mapping for the specified key. |
Set<Map.Entry<A,Set<B>>> |
entrySet()
Returns a Set view of the mappings contained in this map.
|
boolean |
equals(Object obj) |
Set<B> |
get(A key)
Returns the Set associated with the given key.
|
Set<B> |
getValues(A key)
Like get, but returns an empty Set if nothing has been mapped to the key.
|
int |
hashCode() |
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
Set<A> |
keySet()
Get the keySet.
|
void |
put(A key,
B value)
Map a key to a value.
|
void |
putAll(A key,
Collection<B> values)
Map the key to all the given values.
|
void |
putVoid(A key)
Put a key that maps to nothing.
|
Set<B> |
remove(A key)
Removes all mappings for a certain key.
|
boolean |
remove(A key,
B value)
Removes a certain key=value mapping.
|
int |
size()
Returns the number of keys.
|
String |
toString() |
Collection<Set<B>> |
values()
Returns a collection of all value sets.
|
public MultiMap()
MultiMap
.public MultiMap(int capacity)
MultiMap
with the specified initial capacity.capacity
- the initial capacitypublic void put(A key, B value)
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keypublic void putVoid(A key)
key
- key with which an empty set is to be associatedpublic void putAll(A key, Collection<B> values)
key
- key with which the specified values are to be associatedvalues
- values to be associated with the specified keypublic Set<A> keySet()
Map.keySet()
public Set<B> get(A key)
key
- the key whose associated value is to be returnednull
if this map contains no mapping for the keyMap.get(Object)
public Set<B> getValues(A key)
key
- the key whose associated value is to be returnedpublic boolean isEmpty()
true
if this map contains no key-value mappings.true
if this map contains no key-value mappingsMap.isEmpty()
public boolean containsKey(A key)
true
if this map contains a mapping for the specified key.key
- key whose presence in this map is to be testedtrue
if this map contains a mapping for the specified keyMap.containsKey(Object)
public boolean contains(A key, B value)
key
- The keyvalue
- The valuepublic void clear()
Map.clear()
public Set<Map.Entry<A,Set<B>>> entrySet()
Map.entrySet()
public int size()
Map.size()
public Collection<Set<B>> values()
Map.values()
public boolean remove(A key, B value)
key
- key whose mapping is to be removed from the mapvalue
- value whose mapping is to be removed from the maptrue
, if something was removedpublic Set<B> remove(A key)
key
- key whose mapping is to be removed from the mapnull
if there was no mapping for key.Map.remove(Object)