The goog.labs.structs.Multimap Class

goog.labs.structs.Multimap()

Creates a new multimap.

.add(key, value)

Adds the given (key, value) pair to the map. The (key, value) pair is guaranteed to be added.

key {string}
The key to add.
value {*}
The value to add.

.addAllFromMultimap(map)

Adds the contents of the given map/multimap to this multimap.

map {!(goog.labs.structs.Map|goog.labs.structs.Multimap)}
The map to add.

.addAllValues(key, values)

Stores a collection of values to the given key. Does not replace existing (key, value) pairs.

key {string}
The key to add.
values {!Array.<*>}
The values to add.

.clear()

Clears the multimap.

.clone()

Clones this multimap.

returns {!goog.labs.structs.Multimap}
A multimap that contains all the mapping this multimap has.

.containsEntry(key, value)

key {string}
The key to check.
value {string}
The value to check.
returns {boolean}
Whether the (key, value) pair exists in the multimap.

.containsKey(key)

key {string}
The key to check.
returns {boolean}
Whether the multimap contains at least one (key, value) pair with the given key.

.containsValue(value)

value {*}
The value to check.
returns {boolean}
Whether the multimap contains at least one (key, value) pair with the given value.

.get(key)

Gets the values correspond to the given key.

key {string}
The key to retrieve.
returns {!Array.<*>}
An array of values corresponding to the given key. May be empty. Note that the ordering of values are not guaranteed to be consistent.

.getCount()

returns {number}
The count of (key, value) pairs in the map.

.getEntries()

returns {!Array.<!Array>}
An array of entries. Each entry is of the form [key, value].

.getKeys()

returns {!Array.<string>}
An array of unique keys.

.getValues()

returns {!Array.<*>}
An array of values. There may be duplicates.

.isEmpty()

returns {boolean}
Whether the multimap is empty.

.remove(key, value)

Removes a single occurrence of (key, value) pair.

key {string}
The key to remove.
value {*}
The value to remove.
returns {boolean}
Whether any matching (key, value) pair is removed.

.removeAll(key)

Removes all values corresponding to the given key.

key {string}
The key whose values are to be removed.
returns {boolean}
Whether any value is removed.

.replaceValues(key, values)

Replaces all the values for the given key with the given values.

key {string}
The key whose values are to be replaced.
values {!Array.<*>}
The new values. If empty, this is equivalent to {@code removaAll(key)}.