Dictionary

Dictionary object that can accept any elemente as key.  see also an [entry on Feb 13, 2008](http://furyu.tea-nifty.com/annex/2008/02/javascript_bc80.html)

License

(pending) MIT-style license

Author

Copyright

(pending)

Code & Documentation

[nydd jslib](http://code.nydd.org/).

Inspiration

Everything is worthwhile / if the soul isn’t small.

Summary
DictionaryDictionary object that can accept any elemente as key.
Functions
constructorGenerates dictionary object.
setSet a key-value pair to a dictionary instance
getget a value associated by the given key ahead.
removedestructive get().
getKeysreturn an array contains all keys inside this dictionary instance.
collectreturn an array contains all values inside this dictionary instance associated with the given keys.

Functions

constructor

Generates dictionary object.

Examples

var dict = new Dictionary();

Retruns

(Dictionay)

set

this.set = function (key,
value)

Set a key-value pair to a dictionary instance

Type

prototype

Parameters

keyany variable
valueany value

Examples

  • dict.set(‘abc’, 123);
  • dict.set(document.getElementById(‘container’), (function(){...})());

Retruns

(*) pass through ‘value’ argument

get

this.get = function (key)

get a value associated by the given key ahead.  If no value is associated, will return undefined

Type

prototype

Parameters

keyany variable

Examples

  • dict.get(‘abc’);
  • dict.set(document.getElementById(‘container’));

Retruns

(*)

remove

this.remove = function (key)

destructive get().  it will remove a key and return the value associated with it.  If no value is associated, will return undefined.

Type

prototype

Parameters

keyany variable

Examples

  • dict.remove(‘abc’);
  • dict.remove(document.getElementById(‘container’));

Retruns

(*)

getKeys

this.getKeys = function (key)

return an array contains all keys inside this dictionary instance.

Type

prototype

Examples

dict.getKeys();

Retruns

(Array)

collect

this.collect = function (keyList)

return an array contains all values inside this dictionary instance associated with the given keys.  If no keys are passed, will return all values.

Type

prototype

Examples

  • dict.collect([‘abc’]);
  • dict.collect();

Retruns

(Array)

this.set = function (key,
value)
Set a key-value pair to a dictionary instance
this.get = function (key)
get a value associated by the given key ahead.
this.remove = function (key)
destructive get().
this.getKeys = function (key)
return an array contains all keys inside this dictionary instance.
this.collect = function (keyList)
return an array contains all values inside this dictionary instance associated with the given keys.
Close