}
}
@Override
public CloseableIterator<KeyValue<T>> iterator() {
final Cursor cursor = db.cursor();
return new CloseableIterator<KeyValue<T>>() {
private boolean hasNext = cursor.jump();
@Override
public boolean hasNext() {
return hasNext;
}
@Override
public KeyValue<T> next() {
byte[][] keyAndVal = cursor.get(false);
hasNext = cursor.step();
if (!hasNext) {
close();
}
return new KeyValue<>(SerializationUtils.bytesToLong(keyAndVal[0]), SerializationUtils.bytesToObject(keyAndVal[1], getObjectClass()));
}
@Override
public void remove() {
throw new RuntimeException("Not impemented!");
}
@Override
public void closeInt() {
if (hasNext && db != null) {
cursor.disable();
}
}
};
}