entryCursor method
Creates a forward cursor over a key range.
lower and upper are full keys (collection prefix included). The cursor
seeks with a binary search instead of walking the segment from the start.
Implementation
SegmentEntryCursor entryCursor({
Uint8List? lower,
bool includeLower = true,
Uint8List? upper,
bool includeUpper = false,
}) {
var index = 0;
if (lower != null) {
var low = 0;
var high = _indexCount - 1;
while (low <= high) {
final middle = (low + high) >> 1;
final comparison = _compareEntry(middle, lower);
if (comparison < 0) {
low = middle + 1;
} else {
high = middle - 1;
}
}
index = low;
if (!includeLower && index < _indexCount) {
final entryStart = _entryStart(index);
final keyLength = VxsLe.u16(buffer, entryStart);
if (keyLength == lower.length &&
_rangeStartsWith(entryStart + 2, keyLength, lower)) {
index++;
}
}
}
return SegmentEntryCursor._(this, index, upper, includeUpper);
}