trim method

bool trim(
  1. int max
)

Discards the oldest entries over max; the next page starts right after the last remaining one. Not during a store query: its result would continue the discarded part. Returns whether the window changed.

Implementation

bool trim(int max) {
  if (isQuerying || _entries.length <= max) return false;
  for (final stored in _entries.sublist(max)) {
    _ids.remove(stored.id);
  }
  _entries.removeRange(max, _entries.length);
  _next = query.startingAfter(_entries.last.cursor);
  return true;
}