A
- Key typeB
- Value typepublic class MultiMap<A,B> extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map<A,java.util.Set<B>> |
map |
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. |
java.util.Set<java.util.Map.Entry<A,java.util.Set<B>>> |
entrySet()
Returns a Set view of the mappings contained in this map.
|
boolean |
equals(java.lang.Object obj) |
java.util.Set<B> |
get(A key)
Returns the Set associated with the given key.
|
java.util.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. |
java.util.Set<A> |
keySet()
Get the keySet.
|
void |
put(A key,
B value)
Map a key to a value.
|
void |
putAll(A key,
java.util.Collection<B> values)
Map the key to all the given values.
|
void |
putVoid(A key)
Put a key that maps to nothing.
|
java.util.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.
|
java.lang.String |
toString() |
java.util.Collection<java.util.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, java.util.Collection<B> values)
key
- key with which the specified values are to be associatedvalues
- values to be associated with the specified keypublic java.util.Set<A> keySet()
Map.keySet()
public java.util.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 java.util.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 java.util.Set<java.util.Map.Entry<A,java.util.Set<B>>> entrySet()
Map.entrySet()
public int size()
Map.size()
public java.util.Collection<java.util.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 java.util.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)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object