08-27-周三_17-09-29
This commit is contained in:
36
node_modules/d3/src/arrays/bisect.js
generated
vendored
Normal file
36
node_modules/d3/src/arrays/bisect.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import "ascending";
|
||||
|
||||
function d3_bisector(compare) {
|
||||
return {
|
||||
left: function(a, x, lo, hi) {
|
||||
if (arguments.length < 3) lo = 0;
|
||||
if (arguments.length < 4) hi = a.length;
|
||||
while (lo < hi) {
|
||||
var mid = lo + hi >>> 1;
|
||||
if (compare(a[mid], x) < 0) lo = mid + 1;
|
||||
else hi = mid;
|
||||
}
|
||||
return lo;
|
||||
},
|
||||
right: function(a, x, lo, hi) {
|
||||
if (arguments.length < 3) lo = 0;
|
||||
if (arguments.length < 4) hi = a.length;
|
||||
while (lo < hi) {
|
||||
var mid = lo + hi >>> 1;
|
||||
if (compare(a[mid], x) > 0) hi = mid;
|
||||
else lo = mid + 1;
|
||||
}
|
||||
return lo;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var d3_bisect = d3_bisector(d3_ascending);
|
||||
d3.bisectLeft = d3_bisect.left;
|
||||
d3.bisect = d3.bisectRight = d3_bisect.right;
|
||||
|
||||
d3.bisector = function(f) {
|
||||
return d3_bisector(f.length === 1
|
||||
? function(d, x) { return d3_ascending(f(d), x); }
|
||||
: f);
|
||||
};
|
Reference in New Issue
Block a user