public class MultiMap<K,V> extends Object implements Serializable
Constructor and Description |
---|
MultiMap()
Creates a new, empty MultiMap.
|
MultiMap(int initialCapacity)
Creates a new, empty MultiMap with the specified initial capacity
|
MultiMap(int initialCapacity,
int upperCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(K key)
Whether or not the specified key exists.
|
Set<Map.Entry<K,List<V>>> |
entrySet()
Returns a set view of the mappings.
|
List<V> |
get(K key)
Returns the List of values associated with the specified key, or null if the specified key does not exist.
|
V |
getFirst(K key)
Returns the first element associated with the specified key or null if no objects are associated with the key.
|
List<V> |
getIgnoreCase(K key)
Returns a List of all values who's keys (as Strings from toString()) match the specified (case insensitive) key.
|
Object |
getLast(K key)
Returns the last element associated with the specified key or null if no values are associated with the key.
|
Set<K> |
keySet()
Returns a Set of all the keys.
|
void |
put(K key,
V value)
Associates the specified key with an additional value, and does not replace any value already associated with the key.
|
void |
putAll(K key,
List<V> values)
Associates the specified key with the additional elements of the specified List
|
List<V> |
remove(K key)
Removes (and returns) the List of values associated with the specified key.
|
void |
removeAllIgnoreCase(K key)
Removes all keys and their associated values for the specified key where the String representation of the key (from toString()) matches the String representation (case-insensitive) of the specified key.
|
int |
size()
Returns the number of unique keys.
|
void |
sort(K key)
Sorts the objects associated with the specified key alphabetically.
|
String |
toString()
Returns a String representation of the keys and their associated values.
|
String |
toString(String nameValueDelimeter,
String pairsDelimeter,
boolean trailingPairDelimeter,
String nullValue)
Returns a String representation of the keys and their associated values.
|
List<V> |
values()
Returns a (possibly empty) List containing all the values.
|
public MultiMap()
public MultiMap(int initialCapacity)
initialCapacity
- the initial capacitypublic MultiMap(int initialCapacity, int upperCapacity)
public void clear()
public void putAll(K key, List<V> values)
public void sort(K key)
public void put(K key, V value)
public List<V> get(K key)
public V getFirst(K key)
public Object getLast(K key)
public boolean containsKey(K key)
public List<V> remove(K key)
public List<V> getIgnoreCase(K key)
public int size()
public void removeAllIgnoreCase(K key)
public String toString(String nameValueDelimeter, String pairsDelimeter, boolean trailingPairDelimeter, String nullValue)
nameValueDelimeter
- the delimeter between the name and the value.pairsDelimeter
- the delimeter between name-value pairs.trailingPairDelimeter
- whether to append the pairsDelimeter after the last name-value pairnullValue
- the String to print when null values are encountered.