java.lang.Object
dev.sympho.modular_commands.utils.SmartIterator.Wrapper<E>
- Type Parameters:
E- The element type.
- All Implemented Interfaces:
SmartIterator<E>,Iterator<E>
- Direct Known Subclasses:
SmartIterator.ListIterator
- Enclosing interface:
- SmartIterator<E extends @NonNull Object>
public static class SmartIterator.Wrapper<E extends @NonNull Object>
extends Object
implements SmartIterator<E>
A smart iterator that wraps an existing iterator.
Note that, in order to support peek() functionality, the wrapper always
prefetches the next element. This may cause issues with iterators whose next()
method has side effects that are timing-sensitive.
Note also that, naturally, it only tolerates concurrent modifications to the original data source during iteration if the backing iterator does so.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.utils.SmartIterator
SmartIterator.Detachable<E extends @NonNull Object>, SmartIterator.ListIterator<E extends @NonNull Object>, SmartIterator.Wrapper<E extends @NonNull Object> -
Field Summary
Fields inherited from interface dev.sympho.modular_commands.utils.SmartIterator
NO_MORE_ELEMENTS_ERROR -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, removeMethods inherited from interface dev.sympho.modular_commands.utils.SmartIterator
hasNext, toFlux, toSpliterator, toStream
-
Constructor Details
-
Wrapper
Creates a new instance.- Parameters:
backing- The backing iterator.
-
-
Method Details
-
next
-
peek
Description copied from interface:SmartIteratorRetrives the element that will be returned by the next call toIterator.next(), without advancing the iterator.- Specified by:
peekin interfaceSmartIterator<E extends @NonNull Object>- Returns:
- The next element, or
nullif there are no elements remaining.
-