addEntryOrdered method
Adds e so that the entries stay sorted by x: it is appended when its x is not smaller than the last
entry's x, otherwise inserted before the first entry with a larger x. The cached ranges are widened to
include e without a full recalculation.
Implementation
@override
void addEntryOrdered(T e) {
calcMinMaxForEntry(e);
if (entries.isNotEmpty && entries[entries.length - 1].x > e.x) {
var closestIndex = getEntryIndex(e.x, e.y, Rounding.UP);
if (closestIndex < 0) closestIndex = 0;
entries.insert(closestIndex, e);
} else {
entries.add(e);
}
}