/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['collections/Tree.js']) {
  _$jscoverage['collections/Tree.js'] = [];
  _$jscoverage['collections/Tree.js'][1] = 0;
  _$jscoverage['collections/Tree.js'][7] = 0;
  _$jscoverage['collections/Tree.js'][8] = 0;
  _$jscoverage['collections/Tree.js'][9] = 0;
  _$jscoverage['collections/Tree.js'][10] = 0;
  _$jscoverage['collections/Tree.js'][11] = 0;
  _$jscoverage['collections/Tree.js'][12] = 0;
  _$jscoverage['collections/Tree.js'][14] = 0;
  _$jscoverage['collections/Tree.js'][18] = 0;
  _$jscoverage['collections/Tree.js'][31] = 0;
  _$jscoverage['collections/Tree.js'][32] = 0;
  _$jscoverage['collections/Tree.js'][33] = 0;
  _$jscoverage['collections/Tree.js'][34] = 0;
  _$jscoverage['collections/Tree.js'][35] = 0;
  _$jscoverage['collections/Tree.js'][37] = 0;
  _$jscoverage['collections/Tree.js'][38] = 0;
  _$jscoverage['collections/Tree.js'][39] = 0;
  _$jscoverage['collections/Tree.js'][40] = 0;
  _$jscoverage['collections/Tree.js'][41] = 0;
  _$jscoverage['collections/Tree.js'][62] = 0;
  _$jscoverage['collections/Tree.js'][63] = 0;
  _$jscoverage['collections/Tree.js'][64] = 0;
  _$jscoverage['collections/Tree.js'][72] = 0;
  _$jscoverage['collections/Tree.js'][80] = 0;
  _$jscoverage['collections/Tree.js'][87] = 0;
  _$jscoverage['collections/Tree.js'][96] = 0;
  _$jscoverage['collections/Tree.js'][110] = 0;
  _$jscoverage['collections/Tree.js'][111] = 0;
  _$jscoverage['collections/Tree.js'][112] = 0;
  _$jscoverage['collections/Tree.js'][113] = 0;
  _$jscoverage['collections/Tree.js'][114] = 0;
  _$jscoverage['collections/Tree.js'][115] = 0;
  _$jscoverage['collections/Tree.js'][116] = 0;
  _$jscoverage['collections/Tree.js'][117] = 0;
  _$jscoverage['collections/Tree.js'][120] = 0;
  _$jscoverage['collections/Tree.js'][121] = 0;
  _$jscoverage['collections/Tree.js'][122] = 0;
  _$jscoverage['collections/Tree.js'][123] = 0;
  _$jscoverage['collections/Tree.js'][124] = 0;
  _$jscoverage['collections/Tree.js'][126] = 0;
  _$jscoverage['collections/Tree.js'][127] = 0;
  _$jscoverage['collections/Tree.js'][128] = 0;
  _$jscoverage['collections/Tree.js'][129] = 0;
  _$jscoverage['collections/Tree.js'][130] = 0;
  _$jscoverage['collections/Tree.js'][132] = 0;
  _$jscoverage['collections/Tree.js'][133] = 0;
  _$jscoverage['collections/Tree.js'][134] = 0;
  _$jscoverage['collections/Tree.js'][135] = 0;
  _$jscoverage['collections/Tree.js'][136] = 0;
  _$jscoverage['collections/Tree.js'][140] = 0;
  _$jscoverage['collections/Tree.js'][154] = 0;
  _$jscoverage['collections/Tree.js'][155] = 0;
  _$jscoverage['collections/Tree.js'][156] = 0;
  _$jscoverage['collections/Tree.js'][157] = 0;
  _$jscoverage['collections/Tree.js'][158] = 0;
  _$jscoverage['collections/Tree.js'][159] = 0;
  _$jscoverage['collections/Tree.js'][160] = 0;
  _$jscoverage['collections/Tree.js'][161] = 0;
  _$jscoverage['collections/Tree.js'][162] = 0;
  _$jscoverage['collections/Tree.js'][163] = 0;
  _$jscoverage['collections/Tree.js'][164] = 0;
  _$jscoverage['collections/Tree.js'][165] = 0;
  _$jscoverage['collections/Tree.js'][166] = 0;
  _$jscoverage['collections/Tree.js'][167] = 0;
  _$jscoverage['collections/Tree.js'][168] = 0;
  _$jscoverage['collections/Tree.js'][169] = 0;
  _$jscoverage['collections/Tree.js'][170] = 0;
  _$jscoverage['collections/Tree.js'][171] = 0;
  _$jscoverage['collections/Tree.js'][184] = 0;
  _$jscoverage['collections/Tree.js'][185] = 0;
  _$jscoverage['collections/Tree.js'][186] = 0;
  _$jscoverage['collections/Tree.js'][187] = 0;
  _$jscoverage['collections/Tree.js'][188] = 0;
  _$jscoverage['collections/Tree.js'][189] = 0;
  _$jscoverage['collections/Tree.js'][203] = 0;
  _$jscoverage['collections/Tree.js'][204] = 0;
  _$jscoverage['collections/Tree.js'][206] = 0;
  _$jscoverage['collections/Tree.js'][207] = 0;
  _$jscoverage['collections/Tree.js'][208] = 0;
  _$jscoverage['collections/Tree.js'][209] = 0;
  _$jscoverage['collections/Tree.js'][210] = 0;
  _$jscoverage['collections/Tree.js'][211] = 0;
  _$jscoverage['collections/Tree.js'][213] = 0;
  _$jscoverage['collections/Tree.js'][226] = 0;
  _$jscoverage['collections/Tree.js'][227] = 0;
  _$jscoverage['collections/Tree.js'][229] = 0;
  _$jscoverage['collections/Tree.js'][230] = 0;
  _$jscoverage['collections/Tree.js'][231] = 0;
  _$jscoverage['collections/Tree.js'][232] = 0;
  _$jscoverage['collections/Tree.js'][233] = 0;
  _$jscoverage['collections/Tree.js'][234] = 0;
  _$jscoverage['collections/Tree.js'][235] = 0;
  _$jscoverage['collections/Tree.js'][237] = 0;
  _$jscoverage['collections/Tree.js'][250] = 0;
  _$jscoverage['collections/Tree.js'][251] = 0;
  _$jscoverage['collections/Tree.js'][252] = 0;
  _$jscoverage['collections/Tree.js'][253] = 0;
  _$jscoverage['collections/Tree.js'][255] = 0;
  _$jscoverage['collections/Tree.js'][268] = 0;
  _$jscoverage['collections/Tree.js'][269] = 0;
  _$jscoverage['collections/Tree.js'][270] = 0;
  _$jscoverage['collections/Tree.js'][271] = 0;
  _$jscoverage['collections/Tree.js'][273] = 0;
  _$jscoverage['collections/Tree.js'][286] = 0;
  _$jscoverage['collections/Tree.js'][287] = 0;
  _$jscoverage['collections/Tree.js'][289] = 0;
  _$jscoverage['collections/Tree.js'][290] = 0;
  _$jscoverage['collections/Tree.js'][291] = 0;
  _$jscoverage['collections/Tree.js'][292] = 0;
  _$jscoverage['collections/Tree.js'][293] = 0;
  _$jscoverage['collections/Tree.js'][295] = 0;
  _$jscoverage['collections/Tree.js'][308] = 0;
  _$jscoverage['collections/Tree.js'][309] = 0;
  _$jscoverage['collections/Tree.js'][311] = 0;
  _$jscoverage['collections/Tree.js'][312] = 0;
  _$jscoverage['collections/Tree.js'][313] = 0;
  _$jscoverage['collections/Tree.js'][314] = 0;
  _$jscoverage['collections/Tree.js'][315] = 0;
  _$jscoverage['collections/Tree.js'][316] = 0;
  _$jscoverage['collections/Tree.js'][318] = 0;
  _$jscoverage['collections/Tree.js'][329] = 0;
  _$jscoverage['collections/Tree.js'][330] = 0;
  _$jscoverage['collections/Tree.js'][331] = 0;
  _$jscoverage['collections/Tree.js'][332] = 0;
  _$jscoverage['collections/Tree.js'][334] = 0;
  _$jscoverage['collections/Tree.js'][346] = 0;
  _$jscoverage['collections/Tree.js'][347] = 0;
  _$jscoverage['collections/Tree.js'][348] = 0;
  _$jscoverage['collections/Tree.js'][349] = 0;
  _$jscoverage['collections/Tree.js'][350] = 0;
  _$jscoverage['collections/Tree.js'][351] = 0;
  _$jscoverage['collections/Tree.js'][353] = 0;
  _$jscoverage['collections/Tree.js'][354] = 0;
  _$jscoverage['collections/Tree.js'][357] = 0;
  _$jscoverage['collections/Tree.js'][367] = 0;
  _$jscoverage['collections/Tree.js'][368] = 0;
  _$jscoverage['collections/Tree.js'][369] = 0;
  _$jscoverage['collections/Tree.js'][370] = 0;
  _$jscoverage['collections/Tree.js'][371] = 0;
  _$jscoverage['collections/Tree.js'][372] = 0;
  _$jscoverage['collections/Tree.js'][374] = 0;
  _$jscoverage['collections/Tree.js'][375] = 0;
  _$jscoverage['collections/Tree.js'][378] = 0;
  _$jscoverage['collections/Tree.js'][390] = 0;
  _$jscoverage['collections/Tree.js'][391] = 0;
  _$jscoverage['collections/Tree.js'][392] = 0;
  _$jscoverage['collections/Tree.js'][393] = 0;
  _$jscoverage['collections/Tree.js'][394] = 0;
  _$jscoverage['collections/Tree.js'][395] = 0;
  _$jscoverage['collections/Tree.js'][397] = 0;
  _$jscoverage['collections/Tree.js'][400] = 0;
  _$jscoverage['collections/Tree.js'][412] = 0;
  _$jscoverage['collections/Tree.js'][413] = 0;
  _$jscoverage['collections/Tree.js'][414] = 0;
  _$jscoverage['collections/Tree.js'][415] = 0;
  _$jscoverage['collections/Tree.js'][416] = 0;
  _$jscoverage['collections/Tree.js'][417] = 0;
  _$jscoverage['collections/Tree.js'][419] = 0;
  _$jscoverage['collections/Tree.js'][422] = 0;
  _$jscoverage['collections/Tree.js'][429] = 0;
  _$jscoverage['collections/Tree.js'][463] = 0;
}
_$jscoverage['collections/Tree.js'][1]++;
var define = require("../define").define, Collection = require("./Collection"), Iterable = require("./Iterable"), base = require("../base"), multiply = base.string.multiply;
_$jscoverage['collections/Tree.js'][7]++;
var compare = (function (a, b) {
  _$jscoverage['collections/Tree.js'][8]++;
  var ret = 0;
  _$jscoverage['collections/Tree.js'][9]++;
  if (a > b) {
    _$jscoverage['collections/Tree.js'][10]++;
    return 1;
  }
  else {
    _$jscoverage['collections/Tree.js'][11]++;
    if (a < b) {
      _$jscoverage['collections/Tree.js'][12]++;
      return -1;
    }
  }
  _$jscoverage['collections/Tree.js'][14]++;
  return ret;
});
_$jscoverage['collections/Tree.js'][18]++;
var Tree = define([Collection, Iterable], {instance: {__printNode: (function (node, level) {
  _$jscoverage['collections/Tree.js'][31]++;
  var str = [];
  _$jscoverage['collections/Tree.js'][32]++;
  if (node == null || node == undefined) {
    _$jscoverage['collections/Tree.js'][33]++;
    str.push(multiply("\t", level));
    _$jscoverage['collections/Tree.js'][34]++;
    str.push("~");
    _$jscoverage['collections/Tree.js'][35]++;
    console.log(str.join(""));
  }
  else {
    _$jscoverage['collections/Tree.js'][37]++;
    this.__printNode(node.right, level + 1);
    _$jscoverage['collections/Tree.js'][38]++;
    str.push(multiply("\t", level));
    _$jscoverage['collections/Tree.js'][39]++;
    str.push(node.data + "\n");
    _$jscoverage['collections/Tree.js'][40]++;
    console.log(str.join(""));
    _$jscoverage['collections/Tree.js'][41]++;
    this.__printNode(node.left, level + 1);
  }
}), constructor: (function (options) {
  _$jscoverage['collections/Tree.js'][62]++;
  options = options || {};
  _$jscoverage['collections/Tree.js'][63]++;
  this.compare = options.compare || compare;
  _$jscoverage['collections/Tree.js'][64]++;
  this.__root = null;
}), insert: (function (data) {
  _$jscoverage['collections/Tree.js'][72]++;
  throw new Error("Not Implemented");
}), remove: (function (data) {
  _$jscoverage['collections/Tree.js'][80]++;
  throw new Error("Not Implemented");
}), clear: (function () {
  _$jscoverage['collections/Tree.js'][87]++;
  this.__root = null;
}), isEmpty: (function () {
  _$jscoverage['collections/Tree.js'][96]++;
  return this.__root == null;
}), traverseWithCondition: (function (node, order, callback) {
  _$jscoverage['collections/Tree.js'][110]++;
  var cont = true;
  _$jscoverage['collections/Tree.js'][111]++;
  if (node) {
    _$jscoverage['collections/Tree.js'][112]++;
    order = order || Tree.PRE_ORDER;
    _$jscoverage['collections/Tree.js'][113]++;
    if (order === Tree.PRE_ORDER) {
      _$jscoverage['collections/Tree.js'][114]++;
      cont = callback(node.data);
      _$jscoverage['collections/Tree.js'][115]++;
      if (cont) {
        _$jscoverage['collections/Tree.js'][116]++;
        cont = this.traverseWithCondition(node.left, order, callback);
        _$jscoverage['collections/Tree.js'][117]++;
        cont && (cont = this.traverseWithCondition(node.right, order, callback));
      }
    }
    else {
      _$jscoverage['collections/Tree.js'][120]++;
      if (order === Tree.IN_ORDER) {
        _$jscoverage['collections/Tree.js'][121]++;
        cont = this.traverseWithCondition(node.left, order, callback);
        _$jscoverage['collections/Tree.js'][122]++;
        if (cont) {
          _$jscoverage['collections/Tree.js'][123]++;
          cont = callback(node.data);
          _$jscoverage['collections/Tree.js'][124]++;
          cont && (cont = this.traverseWithCondition(node.right, order, callback));
        }
      }
      else {
        _$jscoverage['collections/Tree.js'][126]++;
        if (order === Tree.POST_ORDER) {
          _$jscoverage['collections/Tree.js'][127]++;
          cont = this.traverseWithCondition(node.left, order, callback);
          _$jscoverage['collections/Tree.js'][128]++;
          if (cont) {
            _$jscoverage['collections/Tree.js'][129]++;
            cont && (cont = this.traverseWithCondition(node.right, order, callback));
            _$jscoverage['collections/Tree.js'][130]++;
            cont && (cont = callback(node.data));
          }
        }
        else {
          _$jscoverage['collections/Tree.js'][132]++;
          if (order === Tree.REVERSE_ORDER) {
            _$jscoverage['collections/Tree.js'][133]++;
            cont = this.traverseWithCondition(node.right, order, callback);
            _$jscoverage['collections/Tree.js'][134]++;
            if (cont) {
              _$jscoverage['collections/Tree.js'][135]++;
              cont = callback(node.data);
              _$jscoverage['collections/Tree.js'][136]++;
              cont && (cont = this.traverseWithCondition(node.left, order, callback));
            }
          }
        }
      }
    }
  }
  _$jscoverage['collections/Tree.js'][140]++;
  return cont;
}), traverse: (function (node, order, callback) {
  _$jscoverage['collections/Tree.js'][154]++;
  if (node) {
    _$jscoverage['collections/Tree.js'][155]++;
    order = order || Tree.PRE_ORDER;
    _$jscoverage['collections/Tree.js'][156]++;
    if (order === Tree.PRE_ORDER) {
      _$jscoverage['collections/Tree.js'][157]++;
      callback(node.data);
      _$jscoverage['collections/Tree.js'][158]++;
      this.traverse(node.left, order, callback);
      _$jscoverage['collections/Tree.js'][159]++;
      this.traverse(node.right, order, callback);
    }
    else {
      _$jscoverage['collections/Tree.js'][160]++;
      if (order === Tree.IN_ORDER) {
        _$jscoverage['collections/Tree.js'][161]++;
        this.traverse(node.left, order, callback);
        _$jscoverage['collections/Tree.js'][162]++;
        callback(node.data);
        _$jscoverage['collections/Tree.js'][163]++;
        this.traverse(node.right, order, callback);
      }
      else {
        _$jscoverage['collections/Tree.js'][164]++;
        if (order === Tree.POST_ORDER) {
          _$jscoverage['collections/Tree.js'][165]++;
          this.traverse(node.left, order, callback);
          _$jscoverage['collections/Tree.js'][166]++;
          this.traverse(node.right, order, callback);
          _$jscoverage['collections/Tree.js'][167]++;
          callback(node.data);
        }
        else {
          _$jscoverage['collections/Tree.js'][168]++;
          if (order === Tree.REVERSE_ORDER) {
            _$jscoverage['collections/Tree.js'][169]++;
            this.traverseWithCondition(node.right, order, callback);
            _$jscoverage['collections/Tree.js'][170]++;
            callback(node.data);
            _$jscoverage['collections/Tree.js'][171]++;
            this.traverseWithCondition(node.left, order, callback);
          }
        }
      }
    }
  }
}), forEach: (function (cb, scope, order) {
  _$jscoverage['collections/Tree.js'][184]++;
  if (typeof cb !== "function") {
    _$jscoverage['collections/Tree.js'][185]++;
    throw new TypeError();
  }
  _$jscoverage['collections/Tree.js'][186]++;
  order = order || Tree.IN_ORDER;
  _$jscoverage['collections/Tree.js'][187]++;
  scope = scope || this;
  _$jscoverage['collections/Tree.js'][188]++;
  this.traverse(this.__root, order, (function (node) {
  _$jscoverage['collections/Tree.js'][189]++;
  cb.call(scope, node, this);
}));
}), map: (function (cb, scope, order) {
  _$jscoverage['collections/Tree.js'][203]++;
  if (typeof cb !== "function") {
    _$jscoverage['collections/Tree.js'][204]++;
    throw new TypeError();
  }
  _$jscoverage['collections/Tree.js'][206]++;
  order = order || Tree.IN_ORDER;
  _$jscoverage['collections/Tree.js'][207]++;
  scope = scope || this;
  _$jscoverage['collections/Tree.js'][208]++;
  var construct = this.constructor;
  _$jscoverage['collections/Tree.js'][209]++;
  var ret = new construct();
  _$jscoverage['collections/Tree.js'][210]++;
  this.traverse(this.__root, order, (function (node) {
  _$jscoverage['collections/Tree.js'][211]++;
  ret.insert(cb.call(scope, node, this));
}));
  _$jscoverage['collections/Tree.js'][213]++;
  return ret;
}), filter: (function (cb, scope, order) {
  _$jscoverage['collections/Tree.js'][226]++;
  if (typeof cb !== "function") {
    _$jscoverage['collections/Tree.js'][227]++;
    throw new TypeError();
  }
  _$jscoverage['collections/Tree.js'][229]++;
  order = order || Tree.IN_ORDER;
  _$jscoverage['collections/Tree.js'][230]++;
  scope = scope || this;
  _$jscoverage['collections/Tree.js'][231]++;
  var construct = this.constructor;
  _$jscoverage['collections/Tree.js'][232]++;
  var ret = new construct();
  _$jscoverage['collections/Tree.js'][233]++;
  this.traverse(this.__root, order, (function (node) {
  _$jscoverage['collections/Tree.js'][234]++;
  var include = cb.call(scope, node, this);
  _$jscoverage['collections/Tree.js'][235]++;
  include && ret.insert(node);
}));
  _$jscoverage['collections/Tree.js'][237]++;
  return ret;
}), reduce: (function (fun, accumulator, order) {
  _$jscoverage['collections/Tree.js'][250]++;
  var arr = this.toArray(order);
  _$jscoverage['collections/Tree.js'][251]++;
  var args = [fun];
  _$jscoverage['collections/Tree.js'][252]++;
  if (! base.isUndefined(accumulator) && ! base.isNull(accumulator)) {
    _$jscoverage['collections/Tree.js'][253]++;
    args.push(accumulator);
  }
  _$jscoverage['collections/Tree.js'][255]++;
  return arr.reduce.apply(arr, args);
}), reduceRight: (function (fun, accumulator, order) {
  _$jscoverage['collections/Tree.js'][268]++;
  var arr = this.toArray(order);
  _$jscoverage['collections/Tree.js'][269]++;
  var args = [fun];
  _$jscoverage['collections/Tree.js'][270]++;
  if (! base.isUndefined(accumulator) && ! base.isNull(accumulator)) {
    _$jscoverage['collections/Tree.js'][271]++;
    args.push(accumulator);
  }
  _$jscoverage['collections/Tree.js'][273]++;
  return arr.reduceRight.apply(arr, args);
}), every: (function (cb, scope, order) {
  _$jscoverage['collections/Tree.js'][286]++;
  if (typeof cb !== "function") {
    _$jscoverage['collections/Tree.js'][287]++;
    throw new TypeError();
  }
  _$jscoverage['collections/Tree.js'][289]++;
  order = order || Tree.IN_ORDER;
  _$jscoverage['collections/Tree.js'][290]++;
  scope = scope || this;
  _$jscoverage['collections/Tree.js'][291]++;
  var ret = false;
  _$jscoverage['collections/Tree.js'][292]++;
  this.traverseWithCondition(this.__root, order, (function (node) {
  _$jscoverage['collections/Tree.js'][293]++;
  return (ret = cb.call(scope, node, this));
}));
  _$jscoverage['collections/Tree.js'][295]++;
  return ret;
}), some: (function (cb, scope, order) {
  _$jscoverage['collections/Tree.js'][308]++;
  if (typeof cb !== "function") {
    _$jscoverage['collections/Tree.js'][309]++;
    throw new TypeError();
  }
  _$jscoverage['collections/Tree.js'][311]++;
  order = order || Tree.IN_ORDER;
  _$jscoverage['collections/Tree.js'][312]++;
  scope = scope || this;
  _$jscoverage['collections/Tree.js'][313]++;
  var ret;
  _$jscoverage['collections/Tree.js'][314]++;
  this.traverseWithCondition(this.__root, order, (function (node) {
  _$jscoverage['collections/Tree.js'][315]++;
  ret = cb.call(scope, node, this);
  _$jscoverage['collections/Tree.js'][316]++;
  return ! ret;
}));
  _$jscoverage['collections/Tree.js'][318]++;
  return ret;
}), toArray: (function (order) {
  _$jscoverage['collections/Tree.js'][329]++;
  order = order || Tree.IN_ORDER;
  _$jscoverage['collections/Tree.js'][330]++;
  var arr = [];
  _$jscoverage['collections/Tree.js'][331]++;
  this.traverse(this.__root, order, (function (node) {
  _$jscoverage['collections/Tree.js'][332]++;
  arr.push(node);
}));
  _$jscoverage['collections/Tree.js'][334]++;
  return arr;
}), contains: (function (value) {
  _$jscoverage['collections/Tree.js'][346]++;
  var ret = false;
  _$jscoverage['collections/Tree.js'][347]++;
  var root = this.__root;
  _$jscoverage['collections/Tree.js'][348]++;
  while (root != null) {
    _$jscoverage['collections/Tree.js'][349]++;
    var cmp = this.compare(value, root.data);
    _$jscoverage['collections/Tree.js'][350]++;
    if (cmp) {
      _$jscoverage['collections/Tree.js'][351]++;
      root = root[(cmp == -1)? "left": "right"];
    }
    else {
      _$jscoverage['collections/Tree.js'][353]++;
      ret = true;
      _$jscoverage['collections/Tree.js'][354]++;
      root = null;
    }
}
  _$jscoverage['collections/Tree.js'][357]++;
  return ret;
}), find: (function (value) {
  _$jscoverage['collections/Tree.js'][367]++;
  var ret;
  _$jscoverage['collections/Tree.js'][368]++;
  var root = this.__root;
  _$jscoverage['collections/Tree.js'][369]++;
  while (root != null) {
    _$jscoverage['collections/Tree.js'][370]++;
    var cmp = this.compare(value, root.data);
    _$jscoverage['collections/Tree.js'][371]++;
    if (cmp) {
      _$jscoverage['collections/Tree.js'][372]++;
      root = root[(cmp == -1)? "left": "right"];
    }
    else {
      _$jscoverage['collections/Tree.js'][374]++;
      ret = root.data;
      _$jscoverage['collections/Tree.js'][375]++;
      break;
    }
}
  _$jscoverage['collections/Tree.js'][378]++;
  return ret;
}), findLessThan: (function (value, exclusive) {
  _$jscoverage['collections/Tree.js'][390]++;
  var ret = [], compare = this.compare;
  _$jscoverage['collections/Tree.js'][391]++;
  this.traverseWithCondition(this.__root, exports.IN_ORDER, (function (v) {
  _$jscoverage['collections/Tree.js'][392]++;
  var cmp = compare(value, v);
  _$jscoverage['collections/Tree.js'][393]++;
  if ((! exclusive && cmp == 0) || cmp == 1) {
    _$jscoverage['collections/Tree.js'][394]++;
    ret.push(v);
    _$jscoverage['collections/Tree.js'][395]++;
    return true;
  }
  else {
    _$jscoverage['collections/Tree.js'][397]++;
    return false;
  }
}));
  _$jscoverage['collections/Tree.js'][400]++;
  return ret;
}), findGreaterThan: (function (value, exclusive) {
  _$jscoverage['collections/Tree.js'][412]++;
  var ret = [], compare = this.compare;
  _$jscoverage['collections/Tree.js'][413]++;
  this.traverse(this.__root, exports.REVERSE_ORDER, (function (v) {
  _$jscoverage['collections/Tree.js'][414]++;
  var cmp = compare(value, v);
  _$jscoverage['collections/Tree.js'][415]++;
  if ((! exclusive && cmp == 0) || cmp == -1) {
    _$jscoverage['collections/Tree.js'][416]++;
    ret.push(v);
    _$jscoverage['collections/Tree.js'][417]++;
    return true;
  }
  else {
    _$jscoverage['collections/Tree.js'][419]++;
    return false;
  }
}));
  _$jscoverage['collections/Tree.js'][422]++;
  return ret;
}), print: (function () {
  _$jscoverage['collections/Tree.js'][429]++;
  this.__printNode(this.__root, 0);
}), __iterator__: (function () {
})}, static: {PRE_ORDER: "pre_order", IN_ORDER: "in_order", POST_ORDER: "post_order", REVERSE_ORDER: "reverse_order"}});
_$jscoverage['collections/Tree.js'][463]++;
module.exports = exports = Tree;
_$jscoverage['collections/Tree.js'].source = ["var define = require(\"../define\").define,","        Collection = require(\"./Collection\"),","\t\tIterable = require(\"./Iterable\"),","        base = require(\"../base\"),","        multiply = base.string.multiply;","","var compare = function(a, b) {","    var ret = 0;","    if (a &gt; b) {","        return 1;","    } else if (a &lt; b) {","        return -1;","    }","    return ret;","","};","","var Tree = define([Collection, Iterable], {","","    instance : {","","        /**@lends comb.collections.Tree.prototype*/","","        /**","         * Prints a node","         * @param node node to print","         * @param level the current level the node is at, Used for formatting","         */","        __printNode : function(node, level) {","            //console.log(level);","            var str = [];","            if (node == null || node == undefined) {","                str.push(multiply('\\t', level));","                str.push(\"~\");","                console.log(str.join(\"\"));","            } else {","                this.__printNode(node.right, level + 1);","                str.push(multiply('\\t', level));","                str.push(node.data + \"\\n\");","                console.log(str.join(\"\"));","                this.__printNode(node.left, level + 1);","            }","        },","","        /**","         * Base Class for all tree implementations","         * @constructs","         * @augments comb.collections.Collection","         * @augments comb.collections.Iterable","         * @memberOf comb.collections","         *","         * @param {Object} options options to initialize the tree","         * @param {Function} options.compare function used to compare items in a tree must return an integer","         *  &lt;ul&gt;","         *      &lt;/li&gt;-1 for less than&lt;/li&gt;","         *      &lt;/li&gt;0 for equal&lt;/li&gt;","         *      &lt;/li&gt;1 for greater than&lt;/li&gt;","         *  &lt;/ul&gt;","         *","         */","        constructor : function(options) {","            options = options || {};","            this.compare = options.compare || compare;","            this.__root = null;","        },","","        /**","         * Inserts an item into the tree","         * @param {*} data the item to insert","         */","        insert : function(data) {","            throw new Error(\"Not Implemented\");","        },","","        /**","         * Removes an item from the tree","         * @param {*} data the item to insert","         */","        remove : function(data) {","            throw new Error(\"Not Implemented\");","        },","","        /**","         * Clear all items from a tree","         */","        clear : function() {","            this.__root = null;","        },","","        /**","         * Test if a tree is empty","         *","         * @return {Boolean} true if empty false otherwise","         */","        isEmpty : function() {","            return this.__root == null;","        },","","        /**","         * Traverse a tree until the callback function returns false","         *","         * &lt;p&gt;&lt;b&gt;Not typically used directly&lt;/b&gt;&lt;/p&gt;","         *","         * @param {Object} node the node to start at","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         * @param {Function} callback called for each item, traversal continues until the function returns false","         *","         */","        traverseWithCondition : function(node, order, callback) {","            var cont = true;","            if (node) {","                order = order || Tree.PRE_ORDER;","                if (order === Tree.PRE_ORDER) {","                    cont = callback(node.data);","                    if (cont) {","                        cont = this.traverseWithCondition(node.left, order, callback);","                        cont &amp;&amp; (cont = this.traverseWithCondition(node.right, order, callback));","","                    }","                } else if (order === Tree.IN_ORDER) {","                    cont = this.traverseWithCondition(node.left, order, callback);","                    if (cont) {","                        cont = callback(node.data);","                        cont &amp;&amp; (cont = this.traverseWithCondition(node.right, order, callback));","                    }","                } else if (order === Tree.POST_ORDER) {","                    cont = this.traverseWithCondition(node.left, order, callback);","                    if (cont) {","                        cont &amp;&amp; (cont = this.traverseWithCondition(node.right, order, callback));","                        cont &amp;&amp; (cont = callback(node.data));","                    }","                } else if (order === Tree.REVERSE_ORDER) {","                    cont = this.traverseWithCondition(node.right, order, callback);","                    if (cont) {","                        cont = callback(node.data);","                        cont &amp;&amp; (cont = this.traverseWithCondition(node.left, order, callback));","                    }","                }","            }","            return cont;","        },","","        /**","         * Traverse a tree","         *","         * &lt;p&gt;&lt;b&gt;Not typically used directly&lt;/b&gt;&lt;/p&gt;","         *","         * @param {Object} node the node to start at","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         * @param {Function} callback called for each item","         *","         */","        traverse : function(node, order, callback) {","            if (node) {","                order = order || Tree.PRE_ORDER;","                if (order === Tree.PRE_ORDER) {","                    callback(node.data);","                    this.traverse(node.left, order, callback);","                    this.traverse(node.right, order, callback);","                } else if (order === Tree.IN_ORDER) {","                    this.traverse(node.left, order, callback);","                    callback(node.data);","                    this.traverse(node.right, order, callback);","                } else if (order === Tree.POST_ORDER) {","                    this.traverse(node.left, order, callback);","                    this.traverse(node.right, order, callback);","                    callback(node.data);","                } else if (order === Tree.REVERSE_ORDER) {","                    this.traverseWithCondition(node.right, order, callback);","                    callback(node.data);","                    this.traverseWithCondition(node.left, order, callback);","","                }","            }","        },","","        /**","         * Loop through each item in the tree","         * @param {Function} cb called for each item in the tree","         * @param {Object} [scope=this] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         */","        forEach : function(cb, scope, order) {","            if (typeof cb !== \"function\")","                throw new TypeError();","            order = order || Tree.IN_ORDER;","            scope = scope || this;","            this.traverse(this.__root, order, function(node) {","                cb.call(scope, node, this);","            });","        },","","        /**","         * Loop through each item in the tree, collecting the value returned by the callback funciton.","         * @param {Function} cb called for each item in the tree.","         *                   Whatever the function returns is inserted into the return tree","         * @param {Object} [scope=this] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return {comb.collections.Tree} the tree with the mapped items","         */","        map : function(cb, scope, order) {","            if (typeof cb !== \"function\")","                throw new TypeError();","","            order = order || Tree.IN_ORDER;","            scope = scope || this;","            var construct = this.constructor;","            var ret = new construct();","            this.traverse(this.__root, order, function(node) {","                ret.insert(cb.call(scope, node, this));","            });","            return ret;","        },","","        /**","         * Filters a tree, only returning items that result in true being returned from the callback","         *","         * @param {Function} cb called for each item in the tree","         * @param {Object} [scope=this] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return {comb.collections.Tree} the tree with items that resulted in true being returned from the callback","         */","        filter : function(cb, scope, order) {","            if (typeof cb !== \"function\")","                throw new TypeError();","","            order = order || Tree.IN_ORDER;","            scope = scope || this;","            var construct = this.constructor;","            var ret = new construct();","            this.traverse(this.__root, order, function(node) {","                var include = cb.call(scope, node, this);","                include &amp;&amp; ret.insert(node);","            });","            return ret;","        },","","        /**","         * Reduces a tree","         *","         * @param {Function} cb called for each item in the tree","         * @param [accumulator=First item in tree(Order dependant)] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return the result of the reduce function","         */","        reduce : function(fun, accumulator, order) {","            var arr = this.toArray(order);","            var args = [fun];","            if (!base.isUndefined(accumulator) &amp;&amp; !base.isNull(accumulator)) {","                args.push(accumulator);","            }","            return arr.reduce.apply(arr, args);","        },","","        /**","         * Reduces from right to left","         *","         * @param {Function} cb called for each item in the tree","         * @param [accumulator=First item in tree(Order dependant)] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return the result of the reduce function","         */","        reduceRight : function(fun, accumulator, order) {","            var arr = this.toArray(order);","            var args = [fun];","            if (!base.isUndefined(accumulator) &amp;&amp; !base.isNull(accumulator)) {","                args.push(accumulator);","            }","            return arr.reduceRight.apply(arr, args);","        },","","        /**","         * Determines if every item meets the condition returned by the callback.","         *","         * @param {Function} cb called for each item in the tree","         * @param {Object} [scope=this] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return {Boolean} True if every item passed false otherwise","         */","        every : function(cb, scope, order) {","            if (typeof cb !== \"function\")","                throw new TypeError();","","            order = order || Tree.IN_ORDER;","            scope = scope || this;","            var ret = false;","            this.traverseWithCondition(this.__root, order, function(node) {","                return (ret = cb.call(scope, node, this));","            });","            return ret;","        },","","        /**","         * Determines if some item meet the condition returned by the callback. Traversal ends the first time true is found.","         *","         * @param {Function} cb called for each item in the tree","         * @param {Object} [scope=this] scope to call the function in","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return {Boolean} True if every item passed false otherwise","         */","        some : function(cb, scope, order) {","            if (typeof cb !== \"function\")","                throw new TypeError();","","            order = order || Tree.IN_ORDER;","            scope = scope || this;","            var ret;","            this.traverseWithCondition(this.__root, order, function(node) {","                ret = cb.call(scope, node, this);","                return !ret;","            });","            return ret;","        },","","        /**","         * Converts a tree into an array based on the specified order","         *","         * @param {Tree.PRE_ORDER|Tree.POST_ORDER|Tree.IN_ORDER|Tree.REVERSE_ORDER} [order=Tree.IN_ORDER] the traversal scheme","         *","         * @return {Array} array of all items in the order specified.","         */","        toArray : function(order) {","            order = order || Tree.IN_ORDER;","            var arr = [];","            this.traverse(this.__root, order, function(node) {","                arr.push(node);","            });","            return arr;","        },","","","","        /**","         * Determines if a value is contained in the tree","         * @param {*} value the value to find","         *","         * @return {Boolean} true if the tree contains the item false otherwise.","         */","        contains : function(value) {","            var ret = false;","            var root = this.__root;","            while (root != null) {","                var cmp = this.compare(value, root.data);","                if (cmp) {","                    root = root[(cmp == -1) ? \"left\" : \"right\"];","                } else {","                    ret = true;","                    root = null;","                }","            }","            return ret;","        },","","        /**","         * Finds a value in the tree","         * @param {*} value the value to find","         *","         * @return the value of the node that matched","         */","        find : function(value) {","            var ret;","            var root = this.__root;","            while (root != null) {","                var cmp = this.compare(value, root.data);","                if (cmp) {","                    root = root[(cmp == -1) ? \"left\" : \"right\"];","                } else {","                    ret = root.data;","                    break;","                }","            }","            return ret;","        },","","        /**","         * Find all values less than a value","         * @param {*} value the value to find nodes less than","         * @param {Boolean} [exclusive=false] if true the value will NOT be included in the return array","         *","         * @return {Array} the array containing all values less than","         */","        findLessThan : function(value, exclusive) {","            //find a better way!!!!","            var ret = [], compare = this.compare;","            this.traverseWithCondition(this.__root, exports.IN_ORDER, function(v) {","                var cmp = compare(value, v);","                if ((!exclusive &amp;&amp; cmp == 0) || cmp == 1) {","                    ret.push(v);","                    return true;","                } else {","                    return false;","                }","            });","            return ret;","        },","","        /**","         * Find all greater than a value","         * @param {*} value the value to find nodes greater than","         * @param {Boolean} [exclusive=false] if true the value will NOT be included in the return array","         *","         * @return {Array} the array containing all values greater than","         */","        findGreaterThan : function(value, exclusive) {","            //find a better way!!!!","            var ret = [], compare = this.compare;","            this.traverse(this.__root, exports.REVERSE_ORDER, function(v) {","                var cmp = compare(value, v);","                if ((!exclusive &amp;&amp; cmp == 0) || cmp == -1) {","                    ret.push(v);","                    return true;","                } else {","                    return false;","                }","            });","            return ret;","        },","","        /**","         * Prints a tree to the console.","         */","        print : function() {","            this.__printNode(this.__root, 0);","        },","","\t    __iterator__ : function(){","","\t    }","    },","","    static : {","    /** @lends comb.collections.Tree */","","        /**","         * Pre Order","         */","        PRE_ORDER : \"pre_order\",","","        /**","         * In Order","         */","        IN_ORDER : \"in_order\",","","        /**","         * Post Order","         */","        POST_ORDER:\"post_order\",","","        /**","","         * Reverse Order","         */","        REVERSE_ORDER : \"reverse_order\"","    }","});","/**@ignore*/","module.exports = exports = Tree;",""];
