Class Dictionary
Defined in: dictionary.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A dictionary (or map) for key-value storage and access.
|
Method Attributes | Method Name and Description |
---|---|
clear()
Remove all entries from the dictionary.
|
|
containsKey(key)
Check if the dictionary contains an entry for a key.
|
|
containsValue(value, useStrict)
Check if the dictionary contains an entry with the value.
|
|
get(key)
Get the value for a key.
|
|
getKeys()
Get a list of the keys for all entries in the dictionary.
|
|
put(key, value)
Put / add an entry to the dictionary.
|
|
remove(key)
Remove an entry from the dictionary.
|
|
size()
Get the size of the dictionary.
|
Method Detail
clear()
Remove all entries from the dictionary.
NOTE that this may execute rather slowly, with O(n).
{Boolean}
containsKey(key)
Check if the dictionary contains an entry for a key.
- Parameters:
- {String} key
- the lookup key to check
- Returns:
- {Boolean}
true
if an entry exists, otherwisefalse
{Boolean}
containsValue(value, useStrict)
Check if the dictionary contains an entry with the value.
NOTE that this function may execute rather slowly, with O(n).
- Parameters:
- {any} value
- the value to check
- {Boolean} useStrict Optional
- if
true
entry-values are checked against param value with===
. Iffalse
or omitted, values are compared with each other using==
.
- Returns:
- {Boolean}
true
if an entry exists, otherwisefalse
{any}
get(key)
Get the value for a key.
- Parameters:
- {String} key
- the lookup key with was used to store the entry/value.
- Returns:
- {any} the value for the key, or
undefined
if the dictionary has no entry for the key.
{Array}
getKeys()
Get a list of the keys for all entries in the dictionary.
The returned list has no specific ordering.
NOTE that this may execute rather slowly, with O(n).
NOTE that the returned list is no "view" for the keys, i.e. changes on this list will not be reflected by the dictionary's key-list.
- Returns:
- {Array
} a list of all keys
put(key, value)
Put / add an entry to the dictionary.
- Parameters:
- {String} key
- the lookup key for the value
- {any} value
- the value to store
{Boolean}
remove(key)
Remove an entry from the dictionary.
NOTE that this may execute rather slowly, with O(n).
- Parameters:
- {String} key
- the lookup key for the entry to remove
- Returns:
- {Boolean}
true
if the entry was removed. If there was no entry for the key and nothing was removed,false
is returned.
{Number}
size()
Get the size of the dictionary.
- Returns:
- {Number} the count of entries in the dictionary