/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['collections/BinaryTree.js']) {
  _$jscoverage['collections/BinaryTree.js'] = [];
  _$jscoverage['collections/BinaryTree.js'][1] = 0;
  _$jscoverage['collections/BinaryTree.js'][25] = 0;
  _$jscoverage['collections/BinaryTree.js'][30] = 0;
  _$jscoverage['collections/BinaryTree.js'][31] = 0;
  _$jscoverage['collections/BinaryTree.js'][38] = 0;
  _$jscoverage['collections/BinaryTree.js'][39] = 0;
  _$jscoverage['collections/BinaryTree.js'][40] = 0;
  _$jscoverage['collections/BinaryTree.js'][41] = 0;
  _$jscoverage['collections/BinaryTree.js'][42] = 0;
  _$jscoverage['collections/BinaryTree.js'][43] = 0;
  _$jscoverage['collections/BinaryTree.js'][44] = 0;
  _$jscoverage['collections/BinaryTree.js'][45] = 0;
  _$jscoverage['collections/BinaryTree.js'][46] = 0;
  _$jscoverage['collections/BinaryTree.js'][48] = 0;
  _$jscoverage['collections/BinaryTree.js'][51] = 0;
  _$jscoverage['collections/BinaryTree.js'][57] = 0;
  _$jscoverage['collections/BinaryTree.js'][58] = 0;
  _$jscoverage['collections/BinaryTree.js'][59] = 0;
  _$jscoverage['collections/BinaryTree.js'][60] = 0;
  _$jscoverage['collections/BinaryTree.js'][61] = 0;
  _$jscoverage['collections/BinaryTree.js'][62] = 0;
  _$jscoverage['collections/BinaryTree.js'][63] = 0;
  _$jscoverage['collections/BinaryTree.js'][64] = 0;
  _$jscoverage['collections/BinaryTree.js'][65] = 0;
  _$jscoverage['collections/BinaryTree.js'][66] = 0;
  _$jscoverage['collections/BinaryTree.js'][68] = 0;
  _$jscoverage['collections/BinaryTree.js'][70] = 0;
  _$jscoverage['collections/BinaryTree.js'][71] = 0;
  _$jscoverage['collections/BinaryTree.js'][72] = 0;
  _$jscoverage['collections/BinaryTree.js'][74] = 0;
}
_$jscoverage['collections/BinaryTree.js'][1]++;
var define = require("../define").define, Tree = require("./Tree"), base = require("../base");
_$jscoverage['collections/BinaryTree.js'][25]++;
module.exports = exports = define(Tree, {instance: {insert: (function (data) {
  _$jscoverage['collections/BinaryTree.js'][30]++;
  if (this.__root == null) {
    _$jscoverage['collections/BinaryTree.js'][31]++;
    return (this.__root = {data: data, parent: null, left: null, right: null});
  }
  _$jscoverage['collections/BinaryTree.js'][38]++;
  var compare = this.compare;
  _$jscoverage['collections/BinaryTree.js'][39]++;
  var root = this.__root;
  _$jscoverage['collections/BinaryTree.js'][40]++;
  while (root != null) {
    _$jscoverage['collections/BinaryTree.js'][41]++;
    var cmp = compare(data, root.data);
    _$jscoverage['collections/BinaryTree.js'][42]++;
    if (cmp) {
      _$jscoverage['collections/BinaryTree.js'][43]++;
      var leaf = (cmp == -1)? "left": "right";
      _$jscoverage['collections/BinaryTree.js'][44]++;
      var next = root[leaf];
      _$jscoverage['collections/BinaryTree.js'][45]++;
      if (next == null) {
        _$jscoverage['collections/BinaryTree.js'][46]++;
        return (root[leaf] = {data: data, parent: root, left: null, right: null});
      }
      else {
        _$jscoverage['collections/BinaryTree.js'][48]++;
        root = next;
      }
    }
    else {
      _$jscoverage['collections/BinaryTree.js'][51]++;
      return;
    }
}
}), remove: (function (data) {
  _$jscoverage['collections/BinaryTree.js'][57]++;
  if (this.__root != null) {
    _$jscoverage['collections/BinaryTree.js'][58]++;
    var head = {right: this.__root}, it = head;
    _$jscoverage['collections/BinaryTree.js'][59]++;
    var p, f = null;
    _$jscoverage['collections/BinaryTree.js'][60]++;
    var dir = "right";
    _$jscoverage['collections/BinaryTree.js'][61]++;
    while (it[dir] != null) {
      _$jscoverage['collections/BinaryTree.js'][62]++;
      p = it;
      _$jscoverage['collections/BinaryTree.js'][63]++;
      it = it[dir];
      _$jscoverage['collections/BinaryTree.js'][64]++;
      var cmp = this.compare(data, it.data);
      _$jscoverage['collections/BinaryTree.js'][65]++;
      if (! cmp) {
        _$jscoverage['collections/BinaryTree.js'][66]++;
        f = it;
      }
      _$jscoverage['collections/BinaryTree.js'][68]++;
      dir = (cmp == -1? "left": "right");
}
    _$jscoverage['collections/BinaryTree.js'][70]++;
    if (f != null) {
      _$jscoverage['collections/BinaryTree.js'][71]++;
      f.data = it.data;
      _$jscoverage['collections/BinaryTree.js'][72]++;
      p[p.right == it? "right": "left"] = it[it.left == null? "right": "left"];
    }
    _$jscoverage['collections/BinaryTree.js'][74]++;
    this.__root = head.right;
  }
})}});
_$jscoverage['collections/BinaryTree.js'].source = ["var define = require(\"../define\").define,","        Tree = require(\"./Tree\"),","        base = require(\"../base\");","","/**"," * @class &lt;p&gt;A Search tree that maintains the following properties&lt;/p&gt;"," * &lt;ul&gt;"," *     &lt;li&gt;The left subtree of a node contains only nodes with keys less than the node's key."," *     &lt;li&gt;The right subtree of a node contains only nodes with keys greater than the node's key."," *     &lt;li&gt;Both the left and right subtrees must also be binary search trees."," * &lt;/ul&gt;"," *"," * &lt;b&gt;Performance&lt;/b&gt;"," * &lt;table&gt;"," *     &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Best&lt;/td&gt;&lt;td&gt;Worst&lt;/td&gt;&lt;/tr&gt;"," *     &lt;tr&gt;&lt;td&gt;Space&lt;/td&gt;&lt;td&gt;O(n)&lt;/td&gt;&lt;td&gt;O(n)&lt;/td&gt;&lt;/tr&gt;"," *     &lt;tr&gt;&lt;td&gt;Search&lt;/td&gt;&lt;td&gt;O(log n)&lt;/td&gt;&lt;td&gt;O(n)&lt;/td&gt;&lt;/tr&gt;"," *     &lt;tr&gt;&lt;td&gt;Insert&lt;/td&gt;&lt;td&gt;O(log n)&lt;/td&gt;&lt;td&gt;O(n)&lt;/td&gt;&lt;/tr&gt;"," *     &lt;tr&gt;&lt;td&gt;Delete&lt;/td&gt;&lt;td&gt;O(log n)&lt;/td&gt;&lt;td&gt;O(n)&lt;/td&gt;&lt;/tr&gt;"," * &lt;table&gt;"," * @name BinaryTree"," * @augments comb.collections.Tree"," * @memberOf comb.collections"," */","module.exports = exports = define(Tree, {","    instance : {","        /**@lends comb.collections.BinaryTree.prototype*/","","        insert : function(data) {","            if (this.__root == null) {","                return (this.__root = {","                    data : data,","                    parent : null,","                    left : null,","                    right : null","                });","            }","            var compare = this.compare;","            var root = this.__root;","            while (root != null) {","                var cmp = compare(data, root.data);","                if (cmp) {","                    var leaf = (cmp == -1) ? \"left\" : \"right\";","                    var next = root[leaf];","                    if (next == null) {","                        return (root[leaf] = {data : data, parent : root, left : null, right : null});","                    } else {","                        root = next;","                    }","                } else {","                    return;","                }","            }","        },","","        remove : function(data) {","            if (this.__root != null) {","                var head = {right : this.__root}, it = head;","                var p, f = null;","                var dir = \"right\";","                while (it[dir] != null) {","                    p = it;","                    it = it[dir];","                    var cmp = this.compare(data, it.data);","                    if (!cmp) {","                        f = it;","                    }","                    dir = (cmp == -1 ? \"left\" : \"right\");","                }","                if (f != null) {","                    f.data = it.data;","                    p[p.right == it ? \"right\" : \"left\"] = it[it.left == null ? \"right\" : \"left\"];","                }","                this.__root = head.right;","            }","","        }","    }","});","",""];
