/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['collections/Heap.js']) {
  _$jscoverage['collections/Heap.js'] = [];
  _$jscoverage['collections/Heap.js'][1] = 0;
  _$jscoverage['collections/Heap.js'][5] = 0;
  _$jscoverage['collections/Heap.js'][6] = 0;
  _$jscoverage['collections/Heap.js'][7] = 0;
  _$jscoverage['collections/Heap.js'][8] = 0;
  _$jscoverage['collections/Heap.js'][9] = 0;
  _$jscoverage['collections/Heap.js'][12] = 0;
  _$jscoverage['collections/Heap.js'][16] = 0;
  _$jscoverage['collections/Heap.js'][20] = 0;
  _$jscoverage['collections/Heap.js'][24] = 0;
  _$jscoverage['collections/Heap.js'][28] = 0;
  _$jscoverage['collections/Heap.js'][46] = 0;
  _$jscoverage['collections/Heap.js'][55] = 0;
  _$jscoverage['collections/Heap.js'][56] = 0;
  _$jscoverage['collections/Heap.js'][57] = 0;
  _$jscoverage['collections/Heap.js'][59] = 0;
  _$jscoverage['collections/Heap.js'][69] = 0;
  _$jscoverage['collections/Heap.js'][70] = 0;
  _$jscoverage['collections/Heap.js'][71] = 0;
  _$jscoverage['collections/Heap.js'][72] = 0;
  _$jscoverage['collections/Heap.js'][73] = 0;
  _$jscoverage['collections/Heap.js'][75] = 0;
  _$jscoverage['collections/Heap.js'][76] = 0;
  _$jscoverage['collections/Heap.js'][79] = 0;
  _$jscoverage['collections/Heap.js'][88] = 0;
  _$jscoverage['collections/Heap.js'][89] = 0;
  _$jscoverage['collections/Heap.js'][90] = 0;
  _$jscoverage['collections/Heap.js'][92] = 0;
  _$jscoverage['collections/Heap.js'][101] = 0;
  _$jscoverage['collections/Heap.js'][102] = 0;
  _$jscoverage['collections/Heap.js'][103] = 0;
  _$jscoverage['collections/Heap.js'][105] = 0;
  _$jscoverage['collections/Heap.js'][115] = 0;
  _$jscoverage['collections/Heap.js'][124] = 0;
  _$jscoverage['collections/Heap.js'][136] = 0;
  _$jscoverage['collections/Heap.js'][137] = 0;
  _$jscoverage['collections/Heap.js'][138] = 0;
  _$jscoverage['collections/Heap.js'][139] = 0;
  _$jscoverage['collections/Heap.js'][142] = 0;
  _$jscoverage['collections/Heap.js'][154] = 0;
  _$jscoverage['collections/Heap.js'][155] = 0;
  _$jscoverage['collections/Heap.js'][156] = 0;
  _$jscoverage['collections/Heap.js'][157] = 0;
  _$jscoverage['collections/Heap.js'][160] = 0;
  _$jscoverage['collections/Heap.js'][167] = 0;
  _$jscoverage['collections/Heap.js'][172] = 0;
  _$jscoverage['collections/Heap.js'][173] = 0;
  _$jscoverage['collections/Heap.js'][174] = 0;
  _$jscoverage['collections/Heap.js'][175] = 0;
  _$jscoverage['collections/Heap.js'][176] = 0;
  _$jscoverage['collections/Heap.js'][178] = 0;
  _$jscoverage['collections/Heap.js'][179] = 0;
  _$jscoverage['collections/Heap.js'][180] = 0;
  _$jscoverage['collections/Heap.js'][181] = 0;
  _$jscoverage['collections/Heap.js'][182] = 0;
  _$jscoverage['collections/Heap.js'][190] = 0;
  _$jscoverage['collections/Heap.js'][196] = 0;
  _$jscoverage['collections/Heap.js'][200] = 0;
  _$jscoverage['collections/Heap.js'][201] = 0;
  _$jscoverage['collections/Heap.js'][206] = 0;
  _$jscoverage['collections/Heap.js'][207] = 0;
  _$jscoverage['collections/Heap.js'][212] = 0;
}
_$jscoverage['collections/Heap.js'][1]++;
var define = require("../define").define, Collection = require("./Collection"), base = require("../base");
_$jscoverage['collections/Heap.js'][5]++;
var padding = (function (char, numSpaces) {
  _$jscoverage['collections/Heap.js'][6]++;
  var ret = [];
  _$jscoverage['collections/Heap.js'][7]++;
  for (var i = 0; i < numSpaces; i++) {
    _$jscoverage['collections/Heap.js'][8]++;
    ret.push(char);
}
  _$jscoverage['collections/Heap.js'][9]++;
  return ret.join("");
});
_$jscoverage['collections/Heap.js'][12]++;
module.exports = exports = define(Collection, {instance: {__getParentIndex: (function (index) {
  _$jscoverage['collections/Heap.js'][16]++;
  return Math.floor((index - 1) / 2);
}), __getLeftChildIndex: (function (index) {
  _$jscoverage['collections/Heap.js'][20]++;
  return (index * 2) + 1;
}), __getRightChildIndex: (function (index) {
  _$jscoverage['collections/Heap.js'][24]++;
  return (index * 2) + 2;
}), __makeNode: (function (key, value) {
  _$jscoverage['collections/Heap.js'][28]++;
  return ({key: key, value: value});
}), constructor: (function () {
  _$jscoverage['collections/Heap.js'][46]++;
  this.__heap = [];
}), insert: (function (key, value) {
  _$jscoverage['collections/Heap.js'][55]++;
  if (! base.isString(key)) {
    _$jscoverage['collections/Heap.js'][56]++;
    var l = this.__heap.push(this.__makeNode(key, value));
    _$jscoverage['collections/Heap.js'][57]++;
    this.__upHeap(l - 1);
  }
  else {
    _$jscoverage['collections/Heap.js'][59]++;
    throw TypeError("Invalid key");
  }
}), remove: (function () {
  _$jscoverage['collections/Heap.js'][69]++;
  var ret = undefined, heap = this.__heap, l = heap.length;
  _$jscoverage['collections/Heap.js'][70]++;
  if (l) {
    _$jscoverage['collections/Heap.js'][71]++;
    ret = heap[0];
    _$jscoverage['collections/Heap.js'][72]++;
    if (l == 1) {
      _$jscoverage['collections/Heap.js'][73]++;
      heap.length = 0;
    }
    else {
      _$jscoverage['collections/Heap.js'][75]++;
      heap[0] = heap.pop();
      _$jscoverage['collections/Heap.js'][76]++;
      this.__downHeap(0);
    }
  }
  _$jscoverage['collections/Heap.js'][79]++;
  return ret? ret.value: ret;
}), peek: (function () {
  _$jscoverage['collections/Heap.js'][88]++;
  var ret = undefined, heap = this.__heap, l = heap.length;
  _$jscoverage['collections/Heap.js'][89]++;
  if (l) {
    _$jscoverage['collections/Heap.js'][90]++;
    ret = heap[0];
  }
  _$jscoverage['collections/Heap.js'][92]++;
  return ret? ret.value: ret;
}), peekKey: (function () {
  _$jscoverage['collections/Heap.js'][101]++;
  var ret = undefined, heap = this.__heap, l = heap.length;
  _$jscoverage['collections/Heap.js'][102]++;
  if (l) {
    _$jscoverage['collections/Heap.js'][103]++;
    ret = heap[0];
  }
  _$jscoverage['collections/Heap.js'][105]++;
  return ret? ret.key: ret;
}), __upHeap: (function (index) {
  _$jscoverage['collections/Heap.js'][115]++;
  throw Error("NOT IMPLEMENTED");
}), __downHeap: (function (index) {
  _$jscoverage['collections/Heap.js'][124]++;
  throw Error("NOT IMPLEMENTED");
}), containsKey: (function (key) {
  _$jscoverage['collections/Heap.js'][136]++;
  var heap = this.__heap;
  _$jscoverage['collections/Heap.js'][137]++;
  for (var i = heap.length - 1; i >= 0; i--) {
    _$jscoverage['collections/Heap.js'][138]++;
    if (heap[i].key == key) {
      _$jscoverage['collections/Heap.js'][139]++;
      return true;
    }
}
  _$jscoverage['collections/Heap.js'][142]++;
  return false;
}), containsValue: (function (value) {
  _$jscoverage['collections/Heap.js'][154]++;
  var heap = this.__heap;
  _$jscoverage['collections/Heap.js'][155]++;
  for (var i = heap.length - 1; i >= 0; i--) {
    _$jscoverage['collections/Heap.js'][156]++;
    if (heap[i].value == value) {
      _$jscoverage['collections/Heap.js'][157]++;
      return true;
    }
}
  _$jscoverage['collections/Heap.js'][160]++;
  return false;
}), clear: (function () {
  _$jscoverage['collections/Heap.js'][167]++;
  this.__heap.length = 0;
}), __printNode: (function (index, level) {
  _$jscoverage['collections/Heap.js'][172]++;
  var str = [], node = this.__heap[index];
  _$jscoverage['collections/Heap.js'][173]++;
  if (node == null || node == undefined) {
    _$jscoverage['collections/Heap.js'][174]++;
    str.push(padding("\t", level));
    _$jscoverage['collections/Heap.js'][175]++;
    str.push("~");
    _$jscoverage['collections/Heap.js'][176]++;
    console.log(str.join(""));
  }
  else {
    _$jscoverage['collections/Heap.js'][178]++;
    this.__printNode(this.__getRightChildIndex(index), level + 1);
    _$jscoverage['collections/Heap.js'][179]++;
    str.push(padding("\t", level));
    _$jscoverage['collections/Heap.js'][180]++;
    str.push(node.key + " : " + node.value + "\n");
    _$jscoverage['collections/Heap.js'][181]++;
    console.log(str.join(""));
    _$jscoverage['collections/Heap.js'][182]++;
    this.__printNode(this.__getLeftChildIndex(index), level + 1);
  }
}), print: (function () {
  _$jscoverage['collections/Heap.js'][190]++;
  this.__printNode(0, 0);
}), getters: {count: (function () {
  _$jscoverage['collections/Heap.js'][196]++;
  return this.__heap.length;
}), keys: (function () {
  _$jscoverage['collections/Heap.js'][200]++;
  return this.__heap.map((function (n) {
  _$jscoverage['collections/Heap.js'][201]++;
  return n.key;
}));
}), values: (function () {
  _$jscoverage['collections/Heap.js'][206]++;
  return this.__heap.map((function (n) {
  _$jscoverage['collections/Heap.js'][207]++;
  return n.value;
}));
}), isEmpty: (function () {
  _$jscoverage['collections/Heap.js'][212]++;
  return this.__heap.length == 0;
})}}});
_$jscoverage['collections/Heap.js'].source = ["var define = require(\"../define\").define,","        Collection = require(\"./Collection\"),","        base = require(\"../base\");","","var padding = function(char, numSpaces) {","    var ret = [];","    for (var i = 0; i &lt; numSpaces; i++)","        ret.push(char);","    return ret.join(\"\");","};","","module.exports = exports = define(Collection, {","    instance : {","        /**@lends comb.collections.Heap.prototype*/","        __getParentIndex : function(index) {","            return Math.floor((index - 1) / 2);","        },","","        __getLeftChildIndex : function(index) {","            return (index * 2) + 1;","        },","","        __getRightChildIndex : function(index) {","            return (index * 2) + 2;","        },","","        __makeNode : function(key, value) {","            return {key : key, value : value};","        },","","","        /**","         * Base class for Heap Implementations.","         *","         *","         * @constructs","         * @augments comb.collections.Collection","         * @memberOf comb.collections","         *","         * @property {Number} count the current number of elements.","         * @property {Array} keys the keys of all items in the heap.","         * @property {Array} values the values contained in the heap.","         * @property {Boolean} isEmpty true if the Heap is empty.","         */","        constructor : function() {","            this.__heap = [];","        },","","        /**","         * Insert a key value into the key","         * @param key","         * @param value","         */","        insert : function(key, value) {","            if (!base.isString(key)) {","                var l = this.__heap.push(this.__makeNode(key, value));","                this.__upHeap(l - 1);","            } else {","                throw TypeError(\"Invalid key\");","            }","        },","","        /**","         * Removes the root from the heap","         *","         * @returns the value of the root","         */","        remove : function() {","            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;","        },","","        /**","         * Gets he value of the root node with out removing it.","         *","         * @returns the value of the root","         */","        peek : function() {","            var ret = undefined, heap = this.__heap, l = heap.length;","            if (l) {","                ret = heap[0];","            }","            return ret ? ret.value : ret;","        },","","        /**","         * Gets the key of the root node without removing it.","         *","         * @returns the key of the root","         */","        peekKey : function() {","            var ret = undefined, heap = this.__heap, l = heap.length;","            if (l) {","                ret = heap[0];","            }","            return ret ? ret.key : ret;","        },","","        /**","         * Perform the heapify operation after the an","         * item as been added to the bottom of the heap.","         *","         * @param index the index in which the new item was added","         */","        __upHeap : function(index) {","            throw Error(\"NOT IMPLEMENTED\");","        },","","        /**","         * Heapify the heap after the root has been removed","         *","         * @param index the index of the root","         */","        __downHeap : function(index) {","            throw Error(\"NOT IMPLEMENTED\");","        },","","        /**","         *","         * Determine if the heap contains a particular key.","         *","         * @param key key to test.","         *","         * @returns {Boolean} true if the key is contained in this heap.","         */","        containsKey : function(key) {","            var heap = this.__heap;","            for (var i = heap.length - 1; i &gt;= 0; i--) {","                if (heap[i].key == key) {","                    return true;","                }","            }","            return false;","        },","","        /**","         *","         * Determine if the heap contains a particular value.","         *","         * @param value value to test.","         *","         * @returns {Boolean} true if the value is contained in this heap.","         */","        containsValue : function(value) {","            var heap = this.__heap;","            for (var i = heap.length - 1; i &gt;= 0; i--) {","                if (heap[i].value == value) {","                    return true;","                }","            }","            return false;","        },","","        /**","         * Empty the heap.","         */","        clear : function() {","            this.__heap.length = 0;","        },","","        __printNode : function(index, level) {","            //console.log(level);","            var str = [], node = this.__heap[index];","            if (node == null || node == undefined) {","                str.push(padding('\\t', level));","                str.push(\"~\");","                console.log(str.join(\"\"));","            } else {","                this.__printNode(this.__getRightChildIndex(index), level + 1);","                str.push(padding('\\t', level));","                str.push(node.key + \" : \" + node.value + \"\\n\");","                console.log(str.join(\"\"));","                this.__printNode(this.__getLeftChildIndex(index), level + 1);","            }","        },","","        /**","         * Print the heap.","         */","        print : function() {","            this.__printNode(0, 0);","        },","","        getters : {","","            count : function() {","                return this.__heap.length;","            },","","            keys : function() {","                return this.__heap.map(function(n) {","                    return n.key;","                });","            },","","            values : function() {","                return this.__heap.map(function(n) {","                    return n.value;","                });","            },","","            isEmpty : function() {","                return this.__heap.length == 0;","            }","        }","","","    }","});"];
