server/ol.js
function binarySearchNext(arr, value){
  var low = 0, high = arr.length - 1,
      i, comparison;
  while (low <= high) {
    i = Math.floor((low + high) / 2);
    if (arr[i] < value) { low = i + 1; continue; };
    if (arr[i] > value) { high = i - 1; continue; };
    return i;
  }
  return i;
}
function binarySearchNext(arr, value){
  var low = 0, high = arr.length - 1,
      i, comparison;
  while (low <= high) {
    i = Math.floor((low + high) / 2);
    if (arr[i] < value) { low = i + 1; continue; };
    if (arr[i] > value) { high = i - 1; continue; };
    return i;
  }
  return i;
}
/*
Ol.prototype.getManyAt = function(typeCode, endEditId, cb){
var many = 0
var sts = this.typeCodeSubTypes[typeCode]
for(var j=0;j<sts.length;++j){
var tc = sts[j]
var editIds = this.creationEditIdsByType[tc]
if(editIds){
for(var i=0;i<editIds.length;++i){//TODO use binary search
var editId = editIds[i]
if(editId > endEditId){
break//creationEditIdsByType is sequential
}
++many
}
var destroyedEditIds = this.destructionEditIdsByType[tc]
if(destroyedEditIds){
for(var i=0;i<destroyedEditIds.length;++i){
var editId = destroyedEditIds[i]
if(editId > endEditId){
break//creationEditIdsByType is sequential
}
--many
}
}
}
}
if(cb) cb(many)
return many
} /*
Ol.prototype.getAllIdsOfTypeAt = function(typeCode, endEditId, cb){
var res = []
var sts = this.typeCodeSubTypes[typeCode]
for(var j=0;j<sts.length;++j){
var tc = sts[j]
var ids = this.idsByType[tc] || [];
var editIds = this.creationEditIdsByType[tc]
for(var i=0;i<ids.length;++i){
var id = ids[i]
if(!this.destroyed[id]){
var editId = editIds[i]
if(editId > endEditId){
break//creationEditIdsByType is sequential
}
res.push(id)
}
}

var destroyedEditIds = this.destructionEditIdsByType[tc]
if(destroyedEditIds){
var dids = this.destructionIdsByType[tc] || [];
for(var i=0;i<destroyedEditIds.length;++i){
var editId = destroyedEditIds[i]
if(editId > endEditId){
break//creationEditIdsByType is sequential
}
var id = dids[i]
if(res.indexOf(id) !== -1){
res.splice(res.indexOf(id), 1)
}
--many
}
}
}



if(cb) cb(res)
return res
}
Ol.prototype.getHistoricalCreationsOfType = function(typeCode, cb){
var res = []
var sts = this.typeCodeSubTypes[typeCode]
for(var j=0;j<sts.length;++j){
var tc = sts[j]
var ids = this.idsByType[tc] || [];
var editIds = this.creationEditIdsByType[tc]
for(var i=0;i<ids.length;++i){
var id = ids[i]
if(!this.destroyed[id]){
var editId = editIds[i]
res.push({id: id, editId: editId})
}
}
}
if(cb) cb(res)
return res
}