Package com.complexible.common.collect
Class MarkResetSkippingIterator<T>
- java.lang.Object
-
- com.complexible.common.collect.AbstractSkippingIterator<T>
-
- com.complexible.common.collect.MarkResetSkippingIterator<T>
-
- All Implemented Interfaces:
CloseableIterator<T>
,Copyable<MarkResetIterator<T>>
,MarkResetIterator<T>
,PeekingSkippingIterator<T>
,ResettableIterator<T>
,RestrictedMarkResetIterator<T>
,SkippingIterator<T>
,com.google.common.collect.PeekingIterator<T>
,java.lang.AutoCloseable
,java.util.Iterator<T>
public class MarkResetSkippingIterator<T> extends AbstractSkippingIterator<T> implements RestrictedMarkResetIterator<T>
Implements themark-reset behavior
viaResettableIterator.reset()
andSkippingIterator.skipTo(Object)
. Note: this class does notCloseableIterator.close()
the argument iterator. The class supports restrictions on the underlying iterator, for example, to make sure that it doesn't get out of a specific value range.- Since:
- 8.0
- Author:
- Pavel Klinov
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.complexible.common.base.CloseableIterator
CloseableIterator.AbstractCloseableIterator<T>, CloseableIterator.DelegatingCloseableIterator<T>, CloseableIterator.EmptyCloseableIterator<T>
-
-
Field Summary
-
Fields inherited from class com.complexible.common.collect.AbstractSkippingIterator
mComparator
-
Fields inherited from interface com.complexible.common.collect.SkippingIterator
UNKNOWN_SIZE
-
-
Constructor Summary
Constructors Constructor Description MarkResetSkippingIterator(PeekingSkippingIterator<T> theIterator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected T
computeNext()
Return the next element to be returned by the iteratorprotected T
computeSkipTo(T theTarget)
Returns the element that this iteration has skipped to ornull
if it ran off the end.MarkResetSkippingIterator<T>
copy()
Create a deep copy of the object which does not share any references with the original.void
mark(T element)
Creates a mark from the provided element.protected void
performReset()
void
resetToMark()
Rewinds the position of the iterator to the previously marked element.void
restrict(java.util.function.Predicate<T> restriction)
-
Methods inherited from class com.complexible.common.collect.AbstractSkippingIterator
assertOpen, close, comparator, computeSkipTo, endOfData, estimatedSize, hasNext, isClosed, isLessOrEqualThan, next, peek, remove, reset, resetState, skipTo, skipTo, validateSkipTarget
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.complexible.common.base.CloseableIterator
close
-
Methods inherited from interface com.complexible.common.collect.ResettableIterator
reset
-
-
-
-
Constructor Detail
-
MarkResetSkippingIterator
public MarkResetSkippingIterator(PeekingSkippingIterator<T> theIterator)
-
-
Method Detail
-
restrict
public void restrict(java.util.function.Predicate<T> restriction)
- Specified by:
restrict
in interfaceRestrictedMarkResetIterator<T>
-
computeNext
protected T computeNext()
Description copied from class:AbstractSkippingIterator
Return the next element to be returned by the iterator- Specified by:
computeNext
in classAbstractSkippingIterator<T>
- Returns:
- the next element
-
computeSkipTo
protected T computeSkipTo(T theTarget)
Description copied from class:AbstractSkippingIterator
Returns the element that this iteration has skipped to ornull
if it ran off the end.- Specified by:
computeSkipTo
in classAbstractSkippingIterator<T>
- Parameters:
theTarget
- the skipping target- Returns:
- the first element that is greater or equal to the skipping
target, or
null
if it doesn't exist.
-
performReset
protected void performReset()
- Specified by:
performReset
in classAbstractSkippingIterator<T>
-
mark
public void mark(T element)
Description copied from interface:MarkResetIterator
Creates a mark from the provided element. Note: the reset-to-mark behavior is only guaranteed if the mark is a part of the iterator's output. Specific implementations may impose other restrictions, for example, on the mark being ahead or behind the current iterator's position.- Specified by:
mark
in interfaceMarkResetIterator<T>
- Parameters:
element
- the element to serve as a mark
-
resetToMark
public void resetToMark()
Description copied from interface:MarkResetIterator
Rewinds the position of the iterator to the previously marked element.- Specified by:
resetToMark
in interfaceMarkResetIterator<T>
-
copy
public MarkResetSkippingIterator<T> copy()
Description copied from interface:Copyable
Create a deep copy of the object which does not share any references with the original.
-
-