map
Maps: keys in insertion order (also callable as methods: m.put(k, v)).
#Functions
#map.clearfunction
Removes every key.
map.clear(id: map<K,V>)| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The map. |
Example
const m = map.new<string, float>()
m.put("a", 1.0)
m.clear()Since ChartScript 1
#map.containsfunction
true when the key is in the map.
map.contains(id: map<K,V>, key: K): bool| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The array. |
key | K | The key. |
Returns bool.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const b = m.contains("a")Since ChartScript 1
#map.copyfunction
A shallow copy.
map.copy(id: map<K,V>): map<K,V>| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The map. |
Returns map<K,V>.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const m2 = m.copy()Since ChartScript 1
#map.getfunction
The value of a key, or na.
map.get(id: map<K,V>, key: K): V| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The array. |
key | K | The key. |
Returns V.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const v = m.get("a")Since ChartScript 1
#map.keysfunction
A new array of the keys, in insertion order.
map.keys(id: map<K,V>): array<K>| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The map. |
Returns array<K>.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const ks = m.keys()Since ChartScript 1
#map.new<K,V>function
A new empty map of the key and value types in <> (keys: int, float, bool, string, color or an enum).
Returns map<K,V>.
Example
const m = map.new<string, float>()Since ChartScript 1
#map.putfunction
Sets the value of a key; returns the previous value or na.
map.put(id: map<K,V>, key: K, value: V): V| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The array. |
key | K | The key. |
value | V | The value. |
Returns V.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
m.put("b", 2.0)Since ChartScript 1
#map.put_allfunction
Puts every key and value of id2 into id.
map.put_all(id: map<K,V>, id2: map<K,V>)| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The map. |
id2 | map<K,V> | The map to copy from. |
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const m2 = map.new<string, float>()
m.put_all(m2)Since ChartScript 1
#map.removefunction
Removes a key; returns its value or na.
map.remove(id: map<K,V>, key: K): V| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The array. |
key | K | The key. |
Returns V.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const v = m.remove("a")Since ChartScript 1
#map.sizefunction
The number of keys.
map.size(id: map<K,V>): int| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The map. |
Returns int.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const n = m.size()Since ChartScript 1
#map.valuesfunction
A new array of the values, in insertion order.
map.values(id: map<K,V>): array<V>| Parameter | Type | Description |
|---|---|---|
id | map<K,V> | The map. |
Returns array<V>.
Example
const m = map.new<string, float>()
m.put("a", 1.0)
const vs = m.values()Since ChartScript 1