RiftCursor<K, V> class

Cursor-based iterator for Rift boxes.

Allows iterating over large datasets without loading everything into memory at once. The cursor maintains a position and can move forward or backward through entries, fetching values on demand.

For LazyBox instances, values are loaded lazily from the backend only when accessed. For regular Box instances, values are read from memory.

Usage:

final box = await Rift.openBox('largeData');
final cursor = RiftCursor(box, box.keys.toList());

while (cursor.hasNext) {
  final entry = await cursor.next();
  print('${entry!.key}: ${entry.value}');
}

Constructors

RiftCursor(BoxBase<V> box, List<K> keys, {int batchSize = 50})
Creates a new cursor over box for the given keys.

Properties

hashCode int
The hash code for this object.
no setterinherited
hasNext bool
Whether there are more items ahead of the current position.
no setter
hasPrevious bool
Whether there are items behind the current position.
no setter
isExhausted bool
Whether the cursor has been exhausted (all items consumed).
no setter
length int
The total number of keys in the cursor.
no setter
position int
The current position in the key list (zero-based).
no setter
remaining int
The number of remaining items ahead of the current position.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

collectAll() Future<List<MapEntry<K, V>>>
Collects all remaining entries into a list.
collectAsMap() Future<Map<K, V>>
Collects all remaining entries into a map.
forEach(void action(K key, V value)) Future<void>
Applies an action to each remaining entry.
map<T>(T mapper(K key, V? value)) Future<RiftCursor<K, T>>
Creates a new cursor by transforming each entry with mapper.
next() Future<MapEntry<K, V>?>
Gets the next item and advances the cursor position.
nextBatch() Future<List<MapEntry<K, V>>>
Gets the next batch of items and advances the cursor position.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek() MapEntry<K, V>?
Peeks at the next item without advancing the cursor position.
previous() Future<MapEntry<K, V>?>
Gets the previous item and moves the cursor position backward.
reset() → void
Resets the cursor to the beginning.
resetToEnd() → void
Resets the cursor to the end (before the last item).
seek(int index) → void
Moves the cursor to a specific index position.
skip(int count) → void
Skips count items forward from the current position.
toString() String
A string representation of this object.
inherited
where(bool predicate(K key, V? value)) Future<RiftCursor<K, V>>
Creates a new cursor with only the keys whose values satisfy predicate.

Operators

operator ==(Object other) bool
The equality operator.
inherited