IntervalTree.prototype.add = function()

in src/lib/intervalTree.js [73:91]


IntervalTree.prototype.add = function(data, id) {
  if (this.intervalHash[id]) {
    throw new Error('id ' + id + ' is already registered.');
  }

  if (id == undefined) {
    while (this.intervalHash[this._autoIncrement]) {
      this._autoIncrement++;
    }
    id = this._autoIncrement;
  }

  var itvl = new Interval(data, id, this.startKey, this.endKey);
  this.pointTree.insert([itvl.start, id]);
  this.pointTree.insert([itvl.end,   id]);
  this.intervalHash[id] = itvl;
  this._autoIncrement++;
  _insert.call(this, this.root, itvl);
};