backbee-js-hashmap

A javascript hashmap implementation


Keywords
hashmap
License
GPL-3.0
Install
bower install backbee-js-hashmap

Documentation

backbee/js-hashmap

A javascript hashmap implementation

Installation:

bower install backbee-js-hashmap --save

Properties:

HashMap.length

Returns the number of key/value pairs in the HashMap object.

HashMap.size

Returns the number of key/value pairs in the HashMap object.

Methods

HashMap accessor methods

HashMap.prototype.set(key, value)

Sets the value for the key in the HashMap object. Returns the HashMap object.

HashMap.prototype.get(key)

Returns the value associated to the key, or undefined if there is none.

HashMap.prototype.has(key)

Returns a boolean asserting whether a value has been associated to the key in the HashMap object or not.

Mutator HashMap methods

HashMap.prototype.delete(key)

Removes any value associated to the key and returns the value that HashMap.prototype.has(value) would have previously returned. HashMap.prototype.has(key) will return false afterwards.

HashMap.prototype.clear()

Removes all key/value pairs from the HashMap object.

Mutator Array methods

HashMap.prototype.pop()

Removes the last element from an HashMap and returns that element.

HashMap.prototype.push(value)

Adds one elements to the end of an HashMap and returns the new length of the HashMap.

HashMap.prototype.reverse()

Reverses the order of the elements of an HashMap — the first becomes the last, and the last becomes the first.

HashMap.prototype.shift()

Removes the first element from an HashMap and returns that element.

Accessor methods

HashMap.prototype.concat()

Returns a new HashMap comprised of this HashMap joined with other HashMap(s) and/or value(s).

HashMap.prototype.join(separator)

Joins all elements of an HashMap into a string.

HashMap.prototype.indexOf(value)

Returns the first (least) index of an element within the HashMap equal to the specified value, or -1 if none is found.

HashMap.prototype.lastIndexOf()

Returns the last index of an element within the HashMap equal to the specified value, or -1 if none is found.

Iteration methods

HashMap.prototype.forEach(callback, instance)

Calls callbackFn once for each key-value pair present in the HashMap object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback.

HashMap.prototype.keys()

Returns a new Iterator object that contains the keys for each element in the HashMap object in insertion order.

HashMap.prototype.values()

Returns a new Iterator object that contains the values for each element in the HashMap object in insertion order.

HashMap.prototype.keys()

Returns returns a new Iterator object that contains an array of [key, value] for each element in the HashMap object in insertion order.