MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / lowerBoundObject

Function lowerBoundObject

src/interaction/findPointsAtX.ts:107–117  ·  view source on GitHub ↗
(data: ReadonlyArray<ObjectPoint>, xTarget: number)

Source from the content-addressed store, hash-verified

105};
106
107const lowerBoundObject = (data: ReadonlyArray<ObjectPoint>, xTarget: number): number => {
108 let lo = 0;
109 let hi = data.length;
110 while (lo < hi) {
111 const mid = (lo + hi) >>> 1;
112 const x = data[mid].x;
113 if (x < xTarget) lo = mid + 1;
114 else hi = mid;
115 }
116 return lo;
117};
118
119/**
120 * Finds (at most) one nearest point per series at a given x position.

Callers 1

findPointsAtXFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected