The goog.labs.structs.Map Class

goog.labs.structs.Map()

Creates a new map.

The goog.labs.structs.Map.BrowserFeature Enum

Browser feature enum necessary for map. … more

.addAll(map)

Adds the content of the map to this map. If a new entry uses a key that already exists in this map, the existing key is replaced.

map {!goog.labs.structs.Map}
The map to add.

.clear()

Clears the map to the initial state.

.clone()

Clones this map.

returns {!goog.labs.structs.Map}
The clone of this map.

.containsKey(key)

key {string}
The key to check.
returns {boolean}
True if the map contains the given key.

.containsValue(value)

Whether the map contains the given value. The comparison is done using !== comparator. Also returns true if the passed value is NaN and a NaN value exists in the map.

value {*}
Value to check.
returns {boolean}
True if the map contains the given value.

.get(key, opt_default)

Gets the value for the given key.

key {string}
The key whose value we want to retrieve.
opt_default {*=}
The default value to return if the key does not exist in the map, default to undefined.
returns {*}
The value corresponding to the given key, or opt_default if the key does not exist in this map.

.getCount()

returns {number}
The number of the entries in this map.

.getEntries()

returns {!Array.<Array>}
An array of entries. Each entry is of the form [key, value]. Do not rely on consistent ordering of entries.

.getKeys()

returns {!Array.<string>}
An array of all the keys contained in this map.

.getValues()

returns {!Array.<*>}
An array of all the values contained in this map. There may be duplicates.

.isEmpty()

returns {boolean}
True if the map is empty.

.remove(key)

Removes the map entry with the given key.

key {string}
The key to remove.
returns {boolean}
True if the entry is removed.

.set(key, value)

Adds the (key, value) pair, overriding previous entry with the same key, if any.

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