goog.structs.Map<K, V>
Provided By |
---|
warning Deprecated | This type is misleading: use ES6 Map instead. |
---|
Class for Hash Map datastructure.
new Map<K, V>( opt_map, ...var_args )
Parameters |
|
---|
Instance Methods
this.__iterator__( opt_keys ) → goog.iter.Iterator
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.
warning Deprecated | Call either |
---|
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.addAll( map ) → void
void
Adds multiple key-value pairs from another goog.structs.Map or Object.
warning Deprecated | Use goog.collections.maps.setAll(thisMap, map.entries()) if map is an ES6 or goog.structs Map, or goog.collections.maps.setAll(thisMap, Object.entries(map)) otherwise. |
---|
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.clear() → void
void
this.clone() → goog.structs.Map
goog.structs.Map
Clones a map and returns a new map.
warning Deprecated | Use |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.containsKey( key ) → boolean
boolean
Whether the map contains the given key.
warning Deprecated | Use |
---|
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.containsValue( val ) → boolean
boolean
Whether the map contains the given value. This is O(n).
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.delete( key ) → boolean
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.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.entries() → IteratorIterable<Array<(K|null)>>
IteratorIterable<Array<(K|null)>>
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.equals( otherMap, opt_equalityFn ) → boolean
boolean
Whether this map is equal to the argument map.
warning Deprecated | Use goog.collections.maps.equals(thisMap, otherMap, opt_equalityFn) instead, for alignment with ES6 Map. |
---|
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.forEach<T>( f, opt_obj ) → void
void
Calls the given function on each entry in the map.
warning Deprecated | Use ES6 Iteration instead. |
---|
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.get<DEFAULT>( key, opt_val ) → ?
?
Returns the value for the given key. If the key is not found and the default
value is not given this will return undefined
.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.getCount() → number
number
warning Deprecated | Use the |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getKeyIterator() → goog.iter.Iterator
goog.iter.Iterator
Returns an iterator that iterates over the keys in the map. Removal of keys while iterating might have undesired side effects.
warning Deprecated | Use |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getValueIterator() → goog.iter.Iterator
goog.iter.Iterator
Returns an iterator that iterates over the values in the map. Removal of keys while iterating might have undesired side effects.
warning Deprecated | Use |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getValues() → Array<(V|null)>
Array<(V|null)>
Returns the values of the map.
warning Deprecated | Use |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.has( key ) → boolean
boolean
Whether the map contains the given key.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isEmpty() → boolean
boolean
warning Deprecated | Use the size property and compare against 0, for alignment with ES6 Map. |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.keys() → IteratorIterable<(K|null)>
IteratorIterable<(K|null)>
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.remove( key ) → boolean
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.
warning Deprecated | Use |
---|
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.set( key, value ) → void
void
Adds a key-value pair to the map.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.toObject() → Object
Object
warning Deprecated | Use goog.collections.maps.toObject(thisMap) instead, for aligment with ES6 Maps. |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.transpose() → goog.structs.Map
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)}.
warning Deprecated | Use goog.collections.maps.transpose instead, for alignment with ES6 Maps. |
---|
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.values() → IteratorIterable<(V|null)>
IteratorIterable<(V|null)>
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
Instance Properties
this.size → number
number
Static Functions
Map.defaultEquals( a, b ) → boolean
boolean
Default equality test for values.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|