TradingCharts

Maps

A map is a mutable key/value container. Keys are unique, insertion order is preserved for iteration.

Creation

Call Result
map.new<K, V>() empty
map.copy(src) shallow copy

Lookup and mutation

Call Meaning
.put(k, v) insert or overwrite
.get(k) the value, or na if the key is absent
.contains(k) boolean
.remove(k) delete; returns the previous value or na
.clear() drop everything
.size() element count

Walking a map

for [key, value] in counts
    log.info(key + "=" + str.tostring(value))

Or over the keys and values separately:

keys   = counts.keys()      // array<K>
values = counts.values()    // array<V>

Order

Iteration order equals insertion order. Overwriting an existing key does not reorder it. Deleting and re-inserting does.

Size caps

A map may hold up to 50,000 entries.

See also