Class: Map

bu. Map

Creates a new map given an equality predicate and hash function.


new Map(equals, hash, nbuckets)

Parameters:
Name Type Description
equals function

the equality predicate.

hash function

the hash function.

nbuckets number

the number of buckets.

Source:
bu/collections/map.js

Methods


clear()

Removes all items from the map.

Source:
bu/collections/map.js

del(key)

Removes the item associated with the specified key. Returns the removed value, or null if not found.

Parameters:
Name Type Description
key string

the key to search.

Source:
bu/collections/map.js
Returns:

Removed value.

Type
Object

each(fn)

Calls fn(key, value) for each item in the map, in an undefined order. Returns the number of times fn was called. The result is undefined if the map is mutated during iteration.

Parameters:
Name Type Description
fn function

the function to call.

Source:
bu/collections/map.js
Returns:

the number of times fn is called.

Type
number

get(key)

Returns the value associated to the specified key, or null if not found.

Parameters:
Name Type Description
key Object

the key to search.

Source:
bu/collections/map.js
Returns:

Value associated with key.

Type
Object

has(key)

Returns whether there is a value associated with the specified key.

Parameters:
Name Type Description
key Object

the key to search.

Source:
bu/collections/map.js
Returns:

True if a value exists.

Type
boolean

hashmod(x)

Returns the modulus of hash and number of buckets.

Parameters:
Name Type Description
x number

value to obtain the hash for.

Source:
bu/collections/map.js
Returns:

The modulus.

Type
number

set(key)

Sets the specified key to the specified value, replacing the previous value. Returns the replaced value, or null if no value was replaced.

Parameters:
Name Type Description
key Object

the key to search.

Source:
bu/collections/map.js
Returns:

Replaced value.

Type
Object

size()

Returns the number of items in the map.

Source:
bu/collections/map.js
Returns:

Number of items.

Type
number