Skip to content
Dickson Law edited this page Apr 12, 2023 · 4 revisions

Classes

Map(...)

A data structure that stores string-value pairs. Equivalent to DS Maps.

MapIterator(map)

An iterator class designed to efficiently loop through the map in linear time. It stores its current key in key and current value in value.

  • hasNext(): Return whether there are more values to iterate.
  • next(): Iterate to the next value.
  • remove(): Remove the current value from the map.
  • set(val): Set the current value in the map to the given value.

A for loop using MapIterator takes this form:

for (var i = map.iterator(); i.hasNext(); i.next()) {
	/* Use i.key and i.value here */
}

Ported Methods

Aliases

  • get(key): Same as findValue(key).

New Methods

  • clone(): Return a shallow clone of the map.
  • cloneDeep(): Same as clone(), but also making deep copies of everything in the map.
  • copyDeep(sourceMap): Same as copy(sourceMap), but with deep copies of everything in the source.
  • forEach(func): Call the method or script func for each value in the map. On each iteration, it will be passed the current value followed by the current key.
  • iterator(): Return a new MapIterator set to track this map.
  • keys(): Return an array of all key strings in the map.
  • mapEach(func): Set each value v in the map to func(v). If func throws undefined, the value is removed from the map.

Clone this wiki locally