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.Heap
- Properties
  - count
  - isEmpty
  - keys
  - values
- Methods
  - clear
  - containsKey
  - containsValue
  - insert
  - peek
  - peekKey
  - print
  - remove

# Class comb.collections.Heap

Extends comb.collections.Collection.
Defined in: Heap.js.

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

Class Detail
comb.collections.Heap()
Base class for Heap Implementations.

    this.__heap = [];

Field Detail
{Number} count
the current number of elements.
{Boolean} isEmpty
true if the Heap is empty.
{Array} keys
the keys of all items in the heap.
{Array} values
the values contained in the heap.
Method Detail
clear()
Empty the heap.

    this.__heap.length = 0;

{Boolean} containsKey(key)
Determine if the heap contains a particular key.

Parameters:
key
  key to test.

Returns:
  {Boolean} true if the key is contained in this heap.

    var heap = this.__heap;
    for (var i = heap.length - 1; i >= 0; i--) {
        if (heap[i].key == key) {
            return true;
        }
    }
    return false;

{Boolean} containsValue(value)
Determine if the heap contains a particular value.

Parameters:
value
  value to test.

Returns:
  {Boolean} true if the value is contained in this heap.

    var heap = this.__heap;
    for (var i = heap.length - 1; i >= 0; i--) {
        if (heap[i].value == value) {
            return true;
        }
    }
    return false;

insert(key, value)
Insert a key value into the key

Parameters:
key
value

    if (!base.isString(key)) {
        var l = this.__heap.push(this.__makeNode(key, value));
        this.__upHeap(l - 1);
    } else {
        throw TypeError("Invalid key");
    }

peek()
Gets he value of the root node with out removing it.

Returns:
  the value of the root

    var ret = undefined, heap = this.__heap, l = heap.length;
    if (l) {
        ret = heap[0];
    }
    return ret ? ret.value : ret;

peekKey()
Gets the key of the root node without removing it.

Returns:
  the key of the root

    var ret = undefined, heap = this.__heap, l = heap.length;
    if (l) {
        ret = heap[0];
    }
    return ret ? ret.key : ret;

print()
Print the heap.

    this.__printNode(0, 0);

remove()
Removes the root from the heap

Returns:
  the value of the root

    var ret = undefined, heap = this.__heap, l = heap.length;
    if (l) {
        ret = heap[0];
        if (l == 1) {
            heap.length = 0;
        } else {
            heap[0] = heap.pop();
            this.__downHeap(0);
        }
    }
    return ret ? ret.value : ret;

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