/** * Copyright (C) 2012 Paul Thurlow * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * v0.1.5 */ (function(){var a=function(c){this.options={maxCache:10,enableCache:true,insertOrder:false,returnRoot:false,insert:null,sort:null,clip:null,copy:null,merge:null};this.root={};this.index=0;for(var b in c){if(c.hasOwnProperty(b)){this.options[b]=c[b]}}if(typeof this.options.insert!="function"){this.options.insert=function(e,d){if(this.options.insertOrder&&typeof d.d==="undefined"&&typeof d.o==="undefined"){d={d:d,o:this.index++}}if(e&&e.length){e.push(d)}else{e=[d]}return e}}if(typeof this.options.sort!="function"){if(!this.options.insertOrder){this.options.sort=function(){this.sort()}}else{if(this.options.insertOrder){this.options.sort=function(){this.sort(function(e,d){return e.o-d.o})}}}}if(typeof this.options.clip!="function"){this.options.clip=function(d){if(this.length>d){this.splice(d,this.length-d)}}}if(typeof this.options.copy!="function"){this.options.copy=function(d){return d.slice(0)}}if(typeof this.options.merge!="function"){this.options.merge=function(h,f,g){for(var d=0,e=f.length;d