mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-13 00:44:55 +08:00
2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
define([],function(){"use strict";function a(a,b){if("number"!=typeof a||"number"!=typeof b)throw"Bad range "+a+","+b;this._min=a,this._max=b}function b(a){var b=a.sort(g),c=[],d=b.shift();b.forEach(function(a){a._min<=d._max?a._max>d._max&&(d._max=a._max):(c.push(d),d=a)}),c.push(d),this._ranges=c}function c(a,c){return a instanceof b||(a instanceof Array||(a=[a]),a=new b(a)),c&&a.insertRange(c),a}function d(c,d){for(var e=c.ranges(),f=d.ranges(),g=e.length,h=f.length,i=0,j=0,k=[];g>i&&h>j;){var c=e[i],d=f[j],l=Math.max(c.min(),d.min()),m=Math.min(c.max(),d.max());m>=l&&k.push(new a(l,m)),c.max()>d.max()?++j:++i}return 0==k.length?null:1==k.length?k[0]:new b(k)}function e(a){for(var b=0,c=a.ranges(),d=0;d<c.length;++d){var e=c[d];b+=e.max()-e.min()+1}return b}function f(a,b){return a.min()<b.min()?-1:a.min()>b.min()?1:a.max()<b.max()?-1:b.max()>a.max()?1:0}function g(a,b){return a._min<b._min?-1:a._min>b._min?1:a._max<b._max?-1:b._max>a._max?1:0}return a.prototype.min=function(){return this._min},a.prototype.max=function(){return this._max},a.prototype.contains=function(a){return a>=this._min&&a<=this._max},a.prototype.isContiguous=function(){return!0},a.prototype.ranges=function(){return[this]},a.prototype._pushRanges=function(a){a.push(this)},a.prototype.toString=function(){return"["+this._min+"-"+this._max+"]"},b.prototype.min=function(){return this._ranges[0].min()},b.prototype.max=function(){return this._ranges[this._ranges.length-1].max()},b.prototype.lower_bound=function(a){var b=this.ranges();if(a>this.max())return b.length;if(a<this.min())return 0;for(var c=0,d=b.length-1;d>=c;){var e=Math.floor((c+d)/2);if(a>b[e]._max)c=e+1;else{if(!(a<b[e]._min))return e;d=e-1}}return c},b.prototype.contains=function(a){var b=this.lower_bound(a);return b<this._ranges.length&&this._ranges[b].contains(a)?!0:!1},b.prototype.insertRange=function(a){var b=this.lower_bound(a._min);if(b===this._ranges.length)return void this._ranges.push(a);var c=this.ranges();if(a._max<c[b]._min)return void this._ranges.splice(b,0,a);c[b]._min<a._min&&(a._min=c[b]._min);for(var d=b+1;d<c.length&&c[d]._min<=a._max;)d++;d--,c[d]._max>a._max&&(a._max=c[d]._max),this._ranges.splice(b,d-b+1,a)},b.prototype.isContiguous=function(){return this._ranges.length>1},b.prototype.ranges=function(){return this._ranges},b.prototype._pushRanges=function(a){for(var b=0;b<this._ranges.length;++b)a.push(this._ranges[b])},b.prototype.toString=function(){for(var a="",b=0;b<this._ranges.length;++b)b>0&&(a+=","),a+=this._ranges[b].toString();return a},{Range:a,union:c,intersection:d,coverage:e,rangeOver:f,_rangeOrder:g}});
|
|
//# sourceMappingURL=../../../maps/libs/bbi/spans.js.map
|