# Class: com.pnfsoftware.jeb.util.collect.MultiMap

A map of keys to lists, whose insertion order for the values of a given key is maintained. This class is [serializable](Ser). Null key is allowed except for natural ordering; null values are allowed. 

 Thread\-safety: none. 

 Note: this class does not implement the [Map](Map) interface, but attempts to follow its guidelines and contracts the best it can. One notable exception is that this class does not override hashCode/equals.

## Constructor: MultiMap

Description: Create a new multi\-map.

## Constructor: MultiMap
- parameter: `keyOrder`, type: `com.pnfsoftware.jeb.util.collect.CollectionOrder`

Description: Create a new multi\-map.
parameter: keyOrder: key ordering

## Method: clear

Description: Remove all key\-value mappings.

## Method: containsKey
- parameter: `key`, type: `K`
- return type: `boolean`

Description: Determine whether this multi\-map contains a key.
parameter: key: key
return: true if the key is present

## Method: containsValue
- parameter: `value`, type: `V`
- return type: `boolean`

Description: Determine whether this multi\-map contains a value.
parameter: value: value
return: true if any key maps to the value

## Method: createKey
- parameter: `key`, type: `K`
- return type: `boolean`

Description: Create an explicit entry for a given key. If no values mapped by the given key previously existed, the associated value will be an empty collection.
parameter: key: key
return: true if the map did not already contain the key; false otherwise \(the key entry         existed before\)

## Method: get
- parameter: `key`, type: `K`
- parameter: `safe`, type: `boolean`
- return type: `java.util.List<V>`

Description: Retrieve the list of values associated with the provided key.
parameter: key: a key
parameter: safe: if true, an empty list of values is returned if the key does not exist
return: a list, possibly null or empty \(depending on the `safe` parameter}

## Method: get
- parameter: `key`, type: `K`
- return type: `java.util.List<V>`

Description: Retrieve the list of values associated with the provided key. Same as [get\(key, safe=false\)](#get(Object, boolean)).
parameter: key: a key
return: a list, possibly null if nothing was `put` for the provided key

## Method: getSafe
- parameter: `key`, type: `K`
- return type: `java.util.List<V>`

Description: Retrieve the list of values associated with the provided key. Same as [get\(key, safe=true\)](#get(Object, boolean)).
parameter: key: key
return: a non\-null list of values

## Method: isEmpty
- return type: `boolean`

Description: Determine whether this multi\-map has no values.
return: true if no values are mapped

## Method: keySet
- return type: `java.util.Set<K>`

Description: Retrieve a read\-only view of the keys. 

 WARNING: This method does not respect the [Map#keySet()](Map#keySet()) contract: the set returned is read\-only.
return: read\-only view of the key set

## Method: keySize
- return type: `int`

Description: Get the number of keys in this multi\-map.
return: number of keys, including keys mapped to empty value lists

## Method: put
- parameter: `key`, type: `K`
- parameter: `value`, type: `V`
- return type: `int`

Description: Add a key\-value mapping.
parameter: key: key
parameter: value: value
return: updated count of values associated with the key

## Method: putAll
- parameter: `m`, type: `java.util.Map<? extends K,java.util.List<? extends V>>`

Description: Add all mappings from a map of keys to lists of values.
parameter: m: map of values to add

## Method: putMulti
- parameter: `key`, type: `K`
- parameter: `values`, type: `java.util.Collection<? extends V>`

Description: Add multiple elements mapped by the same key. Note that if an empty collection is provided, the entry for the provided key will not be be explicitly created.
parameter: key: key
parameter: values: values to add

## Method: remove
- parameter: `key`, type: `K`
- return type: `java.util.List<V>`

Description: Remove all values associated with a key.
parameter: key: key
return: removed values, or null if the key was absent

## Method: removeAll
- parameter: `keys`, type: `java.util.Collection<K>`
- return type: `boolean`

Description: Remove all entries mapping to the collection of keys. 

 Similar semantics as [Set#removeAll(Collection)](Set#removeAll(Collection)).
parameter: keys: keys to remove
return: true if the multi\-map was modified

## Method: removeMulti
- parameter: `key`, type: `K`
- parameter: `values`, type: `java.util.Collection<? extends V>`
- return type: `int`

Description: Remove multiple values associated with a key.
parameter: key: key
parameter: values: values to remove
return: number of removed values

## Method: removeMulti
- parameter: `key`, type: `K`
- parameter: `values`, type: `java.util.Collection<? extends V>`
- parameter: `removeEmptyBucket`, type: `boolean`
- return type: `int`

Description: Remove multiple values associated with a key.
parameter: key: key
parameter: values: values to remove
parameter: removeEmptyBucket: true to remove the key if its value list becomes empty
return: number of removed values

## Method: removeValue
- parameter: `key`, type: `K`
- parameter: `value`, type: `V`
- return type: `V`

Description: Remove a value associated with a key.
parameter: key: key
parameter: value: value to remove
return: removed value, or null if no value was removed

## Method: removeValue
- parameter: `key`, type: `K`
- parameter: `value`, type: `V`
- parameter: `removeEmptyBucket`, type: `boolean`
- return type: `V`

Description: Remove a value associated with a key.
parameter: key: key
parameter: value: value to remove
parameter: removeEmptyBucket: true to remove the key if its value list becomes empty
return: removed value, or null if no value was removed

## Method: size
- return type: `int`

Description: Get the number of key\-value mappings \(per Map interface\). That is, the number of values.
return: number of values

## Method: toString
- return type: `java.lang.String`


## Method: values
- return type: `java.util.Collection<V>`

Description: Retrieve all values.
return: read\-only collection of values

