getEntriesForXValue method
Returns all entries whose x equals xValue exactly, in list order, found by binary search over the
x sorted entries. Empty when there is no exact match.
Implementation
@override
List<T> getEntriesForXValue(double xValue) {
final result = <T>[];
var low = 0;
var high = entries.length - 1;
while (low <= high) {
var m = (high + low) ~/ 2;
var entry = entries[m];
if (xValue == entry.x) {
while (m > 0 && entries[m - 1].x == xValue) {
m--;
}
high = entries.length;
while (m < high) {
entry = entries[m];
if (entry.x == xValue) {
result.add(entry);
} else {
break;
}
m++;
}
break;
} else {
if (xValue > entry.x) {
low = m + 1;
} else {
high = m - 1;
}
}
}
return result;
}