Home

# Class goog.structs.Map

Class for Hash Map datastructure.

Instance Method Summary
| `__iterator__(boolean= opt_keys) ⇒ !goog.iter.Iterator` Returns an iterator that iterates over the values or the keys in the map. This throws an exception if the map was mutated since the iterator was created.
| `addAll(?Object map)` Adds multiple key-value pairs from another goog.structs.Map or Object.
| `cleanupKeysArray_()` Cleans up the temp keys array by removing entries that are no longer in the map.
| `clear()` Removes all key-value pairs from the map.
| `clone() ⇒ !goog.structs.Map` Clones a map and returns a new map.
| `containsKey(<Any Type> key) ⇒ boolean` Whether the map contains the given key.
| `containsValue(<Any Type> val) ⇒ boolean` Whether the map contains the given value. This is O(n).
| `equals(?goog.structs.Map otherMap, function (*, *): boolean= opt_equalityFn) ⇒ boolean` Whether this map is equal to the argument map.
| `get(<Any Type> key, <Any Type> opt_val) ⇒ <Any Type>` Returns the value for the given key. If the key is not found and the default value is not given this will return {@code undefined}.
| `getCount() ⇒ number`
| `getKeyIterator() ⇒ !goog.iter.Iterator` Returns an iterator that iterates over the keys in the map. Removal of keys while iterating might have undesired side effects.
| `getKeys() ⇒ !Array` Returns the keys of the map.
| `getValueIterator() ⇒ !goog.iter.Iterator` Returns an iterator that iterates over the values in the map. Removal of keys while iterating might have undesired side effects.
| `getValues() ⇒ !Array` Returns the values of the map.
| `isEmpty() ⇒ boolean`
| `remove(<Any Type> key) ⇒ boolean` Removes a key-value pair based on the key. This is O(logN) amortized due to updating the keys array whenever the count becomes half the size of the keys in the keys array.
| `set(<Any Type> key, <Any Type> value)` Adds a key-value pair to the map.
| `toObject() ⇒ !Object`
| `transpose() ⇒ !goog.structs.Map` Returns a new map in which all the keys and values are interchanged (keys become values and values become keys). If multiple keys map to the same value, the chosen transposed value is implementation-dependent. It acts very similarly to {goog.object.transpose(Object)}.

Static Method Summary
| `defaultEquals(<Any Type> a, <Any Type> b) ⇒ boolean` Default equality test for values.
| `hasKey_(?Object obj, <Any Type> key) ⇒ boolean` Safe way to test for hasOwnProperty. It even allows testing for 'hasOwnProperty'.