forEachRange method
void
forEachRange(})
Visits entries whose key is in [lower, upper) in ascending key order.
Seeks with the skip list, so a narrow range costs O(log n + k) instead of scanning the whole memtable.
Implementation
void forEachRange(
Uint8List? lower,
Uint8List? upper,
void Function(Uint8List key, int chunk, int offset, int length) visit, {
bool includeLower = true,
bool includeUpper = false,
}) {
var index = _firstAtOrAfter(lower);
while (index >= 0) {
final key = keyAt(index);
if (lower != null &&
!includeLower &&
_compareKeyToEntry(lower, index) == 0) {
index = _levels[0][index];
continue;
}
if (upper != null) {
final comparison = _compareKeyToEntry(upper, index);
if (comparison > 0 || (comparison == 0 && !includeUpper)) break;
}
visit(
key,
_valueChunks[index],
_valueOffsets[index],
_valueLengths[index],
);
index = _levels[0][index];
}
}