How to use the binary-search-bounds.lt function in binary-search-bounds

To help you get started, we’ve selected a few binary-search-bounds examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NUbots / NUsight2 / src / client / components / chart / line_chart / view_model.ts View on Github external
private makeLines(series: DataSeries): Group {

    // Get the range we are viewing
    let end = this.now + series.timeDelta
    let start = end - this.model.bufferSeconds

    let values = series.series
    end = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - end))
    start = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - start))
    values = values.slice(start, end)

    // If we have no values, don't draw the line
    if (values.length === 0) {
      return Group.of()
    }

    const lines = []

    if (series.highlight) {
      lines.push(Shape.of(
        PathGeometry.of(values),
        LineAppearance.of({
          stroke: {
            color: '#ffff00',
            width: 8,
github NUbots / NUsight2 / src / client / components / chart / line_chart / view_model.ts View on Github external
const min = this.dataSeries.reduce((minValue, series: DataSeries) => {

        // Get the range we are viewing
        let end = this.now + series.timeDelta
        let start = end - this.model.bufferSeconds

        const values = series.series
        end = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - end))
        start = Math.max(0, bounds.lt(values, Vector2.of(), p => p.x - start))

        return values.slice(start, end).reduce((min, value) => {
          return Math.min(min, value.y)
        }, minValue)
      }, Number.MAX_VALUE)
      return min === Number.MAX_VALUE ? -1 : min
github googleapis / nodejs-spanner / benchmark / ycsb.js View on Github external
const opName = `[${operation.toUpperCase()}]`;

    console.log(
      dedent`${opName}, Operations, ${ops}
      ${opName}, AverageLatency(us), ${stats.mean(lats)}
      ${opName}, LatencyVariance(us), ${stats.stdev(lats)}
      ${opName}, MinLatency(us), ${lats[0]}
      ${opName}, MaxLatency(us), ${lats[lats.length - 1]}
      ${opName}, 95thPercentileLatency(us), ${stats.percentile(lats, 0.95)}
      ${opName}, 99thPercentileLatency(us), ${stats.percentile(lats, 0.99)}
      ${opName}, 99.9thPercentileLatency(us), ${stats.percentile(lats, 0.999)}
      ${opName}, Return=OK, ${ops}`
    );

    for (let i = 0; i < numBucket; i++) {
      const hi = bounds.lt(lats, i + 1);
      const lo = bounds.le(lats, i);
      console.log(`${opName}, ${i}, ${hi - lo}`);
    }

    const lo = bounds.le(lats, numBucket);
    console.log(`${opName}, ${numBucket}, ${ops - lo}`);
  });
}
github mikolalysenko / cdt2d / lib / monotone.js View on Github external
function addPoint(cells, hulls, points, p, idx) {
  var lo = bsearch.lt(hulls, p, testPoint)
  var hi = bsearch.gt(hulls, p, testPoint)
  for(var i=lo; i 1 && orient(
        points[lowerIds[m-2]],
        points[lowerIds[m-1]],
        p) >= 0) {
      cells.push(
        [lowerIds[m-1],
         lowerIds[m-2],
         idx])
      m -= 1
github mikolalysenko / l1-path-finder / lib / planner.js View on Github external
for(var i=0; i= 0) {
      var bb = buckets[idx]
      if(y < bb.y1) {
        //Common case:
        if(node.x >= x) {
          //Connect right
          connectList(bb.right, geom, graph, target, x, y)
        }
        if(node.x <= x) {
          //Connect left
          connectList(bb.left, geom, graph, target, x, y)
        }
        //Connect on
        connectList(bb.on, geom, graph, target, x, y)
      } else {
        //Connect to bottom of bucket above
github gl-vis / gl-pointcloud2d / scatter2d.js View on Github external
var xCoords = this.xCoords
  var xStart = (dataBox[0] - bounds[0] - pixelSize * size * pixelRatio) / boundX
  var xEnd   = (dataBox[2] - bounds[0] + pixelSize * size * pixelRatio) / boundX

  for(var scaleNum = scales.length-1; scaleNum >= 0; --scaleNum) {
    var lod     = scales[scaleNum]
    if(lod.pixelSize < pixelSize && scaleNum > 1) {
      continue
    }

    var intervalStart = lod.offset
    var intervalEnd   = lod.count + intervalStart

    var startOffset = bsearch.ge(xCoords, xStart, intervalStart, intervalEnd-1)
    var endOffset   = bsearch.lt(xCoords, xEnd, startOffset, intervalEnd-1)+1

    if(endOffset > startOffset) {
      gl.drawArrays(gl.POINTS, startOffset, endOffset - startOffset)
    }
  }

  return pickOffset + this.pointCount
}
})()
github gl-vis / gl-plot2d / lib / text.js View on Github external
var screenBox   = plot.screenBox
    var pixelRatio  = plot.pixelRatio
    var tickEnable  = plot.tickEnable
    var tickPad     = plot.tickPad
    var textColor   = plot.tickColor
    var textAngle   = plot.tickAngle
    var tickLength  = plot.tickMarkLength

    var labelEnable = plot.labelEnable
    var labelPad    = plot.labelPad
    var labelColor  = plot.labelColor
    var labelAngle  = plot.labelAngle
    var labelOffset = this.labelOffset[axis]
    var labelCount  = this.labelCount[axis]

    var start = bsearch.lt(tickX, dataBox[axis])
    var end   = bsearch.le(tickX, dataBox[axis+2])

    DATA_AXIS[0]    = DATA_AXIS[1] = 0
    DATA_AXIS[axis] = 1

    SCREEN_OFFSET[axis] = (viewBox[2+axis] + viewBox[axis]) / (screenBox[2+axis] - screenBox[axis]) - 1.0

    var screenScale = 2.0 / screenBox[2+(axis^1)] - screenBox[axis^1]

    SCREEN_OFFSET[axis^1] = screenScale * viewBox[axis^1] - 1.0
    if(tickEnable[axis]) {
      SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * tickPad[axis]
      if(start < end) {
        shader.uniforms.dataAxis     = DATA_AXIS
        shader.uniforms.screenOffset = SCREEN_OFFSET
        shader.uniforms.color        = textColor[axis]

binary-search-bounds

Better binary searching

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis