Class Table Of Contents

- All Classes
- All Files
- API
  - comb
    - logging
      - PropertyConfigurator
      - Level
      - BasicConfigurator
      - Logger
      - appenders
        - RollingFileAppender
        - ConsoleAppender
        - Appender
        - FileAppender
        - JSONAppender
    - PromiseList
    - Promise
    - regexp
    - array
    - string
    - collections
      - Pool
      - Iterable
      - HashTable
      - MaxHeap
      - Heap
      - Stack
      - AVLTree
      - AnderssonTree
      - Collection
      - RedBlackTree
      - Tree
      - Queue
      - BinaryTree
      - PriorityQueue
      - MinHeap
    - plugins
      - Middleware
      - Broadcaster
    - number
    - characters
    - date
- comb.collections.HashTable
- Properties
  - entrySet
  - keys
  - values
- Methods
  - clear
  - concat
  - contains
  - every
  - filter
  - forEach
  - map
  - put
  - reduce
  - reduceRight
  - remove
  - some

# Class comb.collections.HashTable

Extends comb.collections.Collection.

Implementation of a HashTable for javascript. This HashTable implementation allows one to use anything as a key.

NOTE: THIS IS ~ 3 times slower than javascript native objects

A use case for this collection is when one needs to store items in which the key will not be a string, or number

Defined in: HashTable.js.

Methods borrowed from class comb.collections.Collection:
  indexOf, join, lastIndexOf, slice, toString

Class Detail
comb.collections.HashTable()
Field Detail
{Array} entrySet
an array of objects. Each object contains a key, and value property.
{Array} keys
all keys contained in the table
{Array} values
all values contained in the table
Method Detail
clear()
Clears out all items from the table.

    this.__map = {};

{comb.collections.HashTable} concat(hashTable)
Returns a new HashTable containing the values of this HashTable, and the other table. DOES NOT CHANGE THE ORIGINAL!

Parameters:
{comb.collections.HashTable} hashTable
  the hash table to concat with this.

Returns:
  {comb.collections.HashTable} a new HashTable containing all values from both tables.

    if (hashTable instanceof HashTable) {
        var ret = new HashTable();
        var otherEntrySet = hashTable.entrySet.concat(this.entrySet);
        for (var i = otherEntrySet.length - 1; i >= 0; i--) {
            var e = otherEntrySet[i];
            ret.put(e.key, e.value);
        }
        return ret;
    } else {
        throw new TypeError("When joining hashtables the joining arg must be a HashTable");
    }

{Boolean} contains(key)
Tests if the table contains a particular key

Parameters:
key
  the key to test

Returns:
  {Boolean} true if it exitsts false otherwise.

    var hash = hashFunction(key), ret = false;
    var bucket = null;
    if ((bucket = this.__map[hash]) != null) {
        ret = bucket.find(key) != null;
    }
    return ret;

{Boolean} every(cb, scope)
Determines if every item meets the condition returned by the callback.

Parameters:
{Function} cb
  Function to callback with each item, the first aruguments is an object containing a key and value field
{Object} scope Optional, Default: this
  scope to call the function in

Returns:
  {Boolean} True if every item passed false otherwise

    var es = this.__entrySet();
    return es.every.apply(es, arguments);

{comb.collections.HashTable} filter(cb, scope)
Creates a new HashTable containg values that passed the filtering function.

Parameters:
{Function} cb
  Function to callback with each item, the first aruguments is an object containing a key and value field
{Object} scope
  the scope to call the function.

Returns:
  {comb.collections.HashTable} the HashTable containing the values that passed the filter.

    var es = this.__entrySet(), ret = new HashTable();
    es = es.filter.apply(es, arguments);
    for (var i = es.length - 1; i >= 0; i--) {
        var e = es[i];
        ret.put(e.key, e.value);
    }
    return ret;

forEach(cb, scope)
Loop through each value in the hashtable

Parameters:
{Function} cb
  the function to call with an object containing a key and value field
{Object} scope
  the scope to call the funciton in

    var es = this.__entrySet(), l = es.length, f = cb.bind(scope || this);
    es.forEach.apply(es, arguments);

{Array} map(cb, scope)
Loop through each value in the hashtable, collecting the value returned by the callback function.

Parameters:
{Function} cb
  Function to callback with each item, the first aruguments is an object containing a key and value field
{Object} scope Optional, Default: this
  scope to call the function in

Returns:
  {Array} an array containing the mapped values.

    var es = this.__entrySet(), ret = new HashTable();
    return es.map.apply(es, arguments);

put(key, value)
Put a key, value pair into the table NOTE : the collection will not check if the key previously existed.

Parameters:
{Anything} key
  the key to look up the object.
{Anything} value
  the value that corresponds to the key.

Returns:
  the value

    var hash = hashFunction(key);
    var bucket = null;
    if ((bucket = this.__map[hash]) == null) {
        bucket = (this.__map[hash] = new Bucket());
    }
    bucket.pushValue(key, value);
    return value;

reduce(callback, initialValue)
Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.

Parameters:
{Function} callback
  Function to execute on each value in the array.
initialValue
  Value to use as the first argument to the first call of the callback..

    var es = this.__entrySet();
    return es.reduce.apply(es, arguments);

reduceRight(callback, initialValue)
Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.

Parameters:
{Function} callback
  Function to execute on each value in the array.
initialValue
  Value to use as the first argument to the first call of the callback..

    var es = this.__entrySet();
    return es.reduceRight.apply(es, arguments);

remove(key)
Remove a key value pair from the table.

Parameters:
key
  the key of the key value pair to remove.

Returns:
  the removed value.

    var hash = hashFunction(key), ret = null;
    var bucket = this.__map[hash];
    if (bucket) {
        ret = bucket.remove(key);
    }
    return ret;

{Boolean} some(cb, scope)
Determines if some items meet the condition returned by the callback.

Parameters:
{Function} cb
  Function to callback with each item, the first aruguments is an object containing a key and value field
{Object} scope Optional, Default: this
  scope to call the function in

Returns:
  {Boolean} True if some items passed false otherwise

    var es = this.__entrySet();
    return es.some.apply(es, arguments);

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Jan 31 2012 16:14:11 GMT-0600 (CST)