Class: FastMap

Stork. FastMap

new Stork.FastMap(map)

A FastMap has the key-to-value benefits of a map and iteration benefits of an array. This is especially beneficial when most of the time the contents of the structure need to be iterated and order doesn't matter (since removal performs a swap which breaks insertion order).

Name Type Description
map Stork.FastMap | object optional

Members

indicesObject

An object of key to index mappings.

keysArray

An array of the keys in this map.

okeysArray

An array of the original keys in this map.

valuesArray

An array of the values in this map.

Methods

get(key){V}

Returns the value mapped by the given key.

Name Type Description
key String

has(key){Boolean}

Returns whether this map has a value for the given key.

Name Type Description
key String

hasOverlap(map){Boolean}

Returns whether the given input has overlap with keys in this map.

Name Type Description
map FastMap | Object

indexOf(key){Number}

Returns the index of the value in the array given a key.

Name Type Description
key String

Overwrites this map with another map.

Name Type Description
map Stork.FastMap

put(key, value, originalKey){Stork.FastMap}

Puts the value in the map by the given key.

Name Type Description
key String
value V
originalKey K

Puts all keys & values on the given map into this map overwriting any existing values mapped by similar keys.

Name Type Description
map FastMap | Object

Rebuilds the index based on the keys.

Returns:
The reference to this map.

Removes the value by a given key

Name Type Description
key String

Removes the value & key at the given index.

Name Type Description
index Number

Resets the map by initializing the values, keys, and indexes.

Reverses the order of the underlying values & keys.

Returns:
The referense to this map.

size(){Number}

Returns the number of elements in the map.

Sorts the underlying values & keys given a value compare function.

Name Type Description
comparator function

A function which accepts two values and returns a number used for sorting. If the first argument is less than the second argument, a negative number should be returned. If the arguments are equivalent then 0 should be returned, otherwise a positive number should be returned.

Returns:
The reference to this map.