Class: LinkedMap

LinkedMap

new LinkedMap()

Create a LinkedMap structure.
Source:

Methods

clear()

Remove all entries from the LinkedMap.
Source:

each(callback, context)

Iterate through each entry in the LinkedMap.
Parameters:
Name Type Description
callback function The required callback function that will be invoked for each entry. It receives the key and the value as parameters. To break out of the loop, return false.
context Object The optional context with which to call the callback. Effectively, the value of this.
Source:

get(key) → {*|null}

Lookup the value associated with the given key.
Parameters:
Name Type Description
key The key for which to return the value.
Source:
Returns:
The value if it exists, or null if it does not.
Type
* | null
Get the first value in the linked list.
Source:
Returns:
The first value, or null if the structure is empty.
Type
* | null

headKey() → {*|null}

Get the first key in the linked list.
Source:
Returns:
The first key, or null if the structure is empty.
Type
* | null

keys() → {Array}

Obtain a list of all keys known to the LinkedMap, in order.
Source:
Returns:
The list of keys.
Type
Array

next(key, circular) → {*}

Obtain the next value in the linked list for the given key.
Parameters:
Name Type Description
key The key for which to return the next value.
circular Boolean Optionally supply true to treat the linked list circularly. Defaults to false.
Source:
Returns:
The next value, or null if the given key was not found or the given key is the last in the linked list and circular is false.
Type
*

nextKey(key, circular) → {*}

Obtain the next key in the linked list for the given key.
Parameters:
Name Type Description
key The key for which to return the next key.
circular Boolean Optionally supply true to treat the linked list circularly. Defaults to false.
Source:
Returns:
The next key, or null if the given key was not found or the given key is the last in the linked list and circular is false.
Type
*

pop() → {*|null}

Obtain and remove the last value from the linked list.
Source:
Returns:
The last value removed, or null if the structure is empty.
Type
* | null

previous(key, circular) → {*}

Obtain the previous value in the linked list for the given key.
Parameters:
Name Type Description
key The key for which to return the previous value.
circular Boolean Optionally supply true to treat the linked list circularly. Defaults to false.
Source:
Returns:
The previous value, or null if the given key was not found or the given key is the last in the linked list and circular is false.
Type
*

previousKey(key, circular) → {*}

Obtain the previous key in the linked list for the given key.
Parameters:
Name Type Description
key The key for which to return the previous key.
circular Boolean Optionally supply true to treat the linked list circularly. Defaults to false.
Source:
Returns:
The previous key, or null if the given key was not found or the given key is the last in the linked list and circular is false.
Type
*

push(key, value)

Append the given key-value pair to the end of the linked list.
Parameters:
Name Type Description
key The key to append.
value The value to append.
Source:

remove(key) → {*|null}

Remove the entry for the given key.
Parameters:
Name Type Description
key The key for which to remove the entry.
Source:
Returns:
The value associated with the given key, or null if key does not exist.
Type
* | null

shift() → {*|null}

Obtain and remove the first value from the linked list.
Source:
Returns:
The first value removed, or null if the structure is empty.
Type
* | null

size() → {number}

Obtain the number of elements in the LinkedMap.
Source:
Returns:
The number of elements.
Type
number

tail() → {*|null}

Get the last value in the linked list.
Source:
Returns:
The last value, or null if the structure is empty.
Type
* | null

tailKey() → {*|null}

Get the last key in the linked list.
Source:
Returns:
The last key, or null if the structure is empty.
Type
* | null

unshift(key, value)

Prepend the given key-value pair to the front of the linked list.
Parameters:
Name Type Description
key The key to prepend.
value The value to prepend.
Source:

values() → {Array}

Obtain a list of all values known to the LinkedMap, in order.
Source:
Returns:
Type
Array