SyncIteratorJava

interface SyncIteratorJava<T>

An iterator over a collection. Allows to sequentially access the elements. Must be closed at the end to cleanup resources.

Instances of this interface are not thread-safe and shall not be used from concurrent coroutines.

Example:

SyncIteratorJava<SyncMapJava.Item> iterator = syncMap.queryItems();

try {
SettableFuture<Boolean> hasNextFuture = SettableFuture.create();
iterator.hasNext(hasNextFuture::set);

while (hasNextFuture.get()) {
SyncMapJava.Item item = iterator.next();
System.out.println(item);

hasNextFuture = SettableFuture.create();
iterator.hasNext(hasNextFuture::set);
}
} finally {
iterator.close();
}

Functions

Link copied to clipboard

Returns true to callback if SyncIteratorJava has more elements (In other words, returns true if next() would return an element rather than throwing an exception).

Link copied to clipboard
abstract fun next(): T

Returns the next element in the iteration.