在回顾"Crossfilter"源代码时,我遇到了一个使用>>的函数.以下是功能:
// Similar to bisectLeft, but returns an insertion point which comes after (to
// the right of) any existing entries of x in a.
//
// The returned insertion point i partitions the array into two halves so that
// all v <= x for v in a[lo:i] for the left side and all v > x for v in
// a[i:hi] for the right side.
function bisectRight(a, x, lo, hi) {
while (lo < hi) {
var mid = lo + hi >> 1;
if (x < f(a[mid])) hi = mid;
else lo = mid + 1;
}
return lo;
}
Run Code Online (Sandbox Code Playgroud)
谷歌没有返回任何结果,我以前从未见过这个.在此先感谢您的帮助.
它是符号传播的右移运算符:
该运算符将第一个操作数向右移动指定的位数.向右移位的多余位被丢弃.最左边的位的副本从左侧移入.由于新的最左边的位与前一个最左边的位具有相同的值,所以符号位(最左边的位)不会改变.因此,名称"标志传播".