Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (20 sloc) 1.63 KB
description
A mapping of generic keys to generic values.

Map

API

The Map API is very similar to JavaScript's (MDN), with the notable difference that a get with a key that does not exist results in an error, because undefined cannot be represented. Iterators are not implemented yet.

Constructor

  • new Map<K,V>() Constructs a new map mapping keys of type K to values of type V.

Instance

Fields

  • Map#size: i32 readonly The current number of key-value pairs in this map.

Methods

  • Map#clear(): void Clears the map, deleting all key-value pairs.
  • Map#delete(key: K): bool Deletes the key-value pair for the corresponding key. Returns true if the key did exist, otherwise false.
  • Map#get(key: K): V Gets the value corresponding to the specified key. Traps if the key does not exist because "not found" cannot be represented in all cases (use Map#has to check).
  • Map#has(key: K): bool Tests if the specified key exists.
  • Map#keys(): Array<K> Gets the keys contained in this map as an array, in insertion order. This is preliminary while iterators are not supported.
  • Map#set(key: K, value: V): void Sets the value for the specified key. Creates a new key-value pair if the key did not exist.
  • Map#values(): Array<V> Gets the values contained in this map as an array, in insertion order. This is preliminary while iterators are not supported.
  • Map#toString(): string Returns a string representation of this map.
You can’t perform that action at this time.