Package com.complexible.common.collect
Class DelegatingSkippingIterator<T>
- java.lang.Object
-
- com.complexible.common.collect.DelegatingSkippingIterator<T>
-
- All Implemented Interfaces:
CloseableIterator<T>,ResettableIterator<T>,SkippingIterator<T>,java.lang.AutoCloseable,java.util.Iterator<T>
public class DelegatingSkippingIterator<T> extends java.lang.Object implements SkippingIterator<T>
-
-
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 Modifier and Type Field Description protected SkippingIterator<T>it-
Fields inherited from interface com.complexible.common.collect.SkippingIterator
UNKNOWN_SIZE
-
-
Constructor Summary
Constructors Constructor Description DelegatingSkippingIterator(SkippingIterator<T> it)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.util.Comparator<T>comparator()Returns the comparator for this iterator that specifies the order in which the elements are returned.longestimatedSize()Returns the estimated size of this iterator without advancing the iterator orSkippingIterator.UNKNOWN_SIZEif the estimate is not known.booleanhasNext()Tnext()voidreset()Resets the iterator to the beginning so the followingIterator.next()call will return the first element in this iteration.booleanskipTo(T e)Moves the iterators position to the next element which is greater than or equal totheElement.booleanskipTo(T theElement, T theBound)Same contract asSkippingIterator.skipTo(Object)but skipping is bounded: if the implementation can determine that the next element after target is greater than the bound, it can return false.
-
-
-
Field Detail
-
it
protected final SkippingIterator<T> it
-
-
Constructor Detail
-
DelegatingSkippingIterator
public DelegatingSkippingIterator(SkippingIterator<T> it)
-
-
Method Detail
-
reset
public void reset()
Description copied from interface:ResettableIteratorResets the iterator to the beginning so the followingIterator.next()call will return the first element in this iteration.- Specified by:
resetin interfaceResettableIterator<T>
-
close
public void close() throws java.lang.RuntimeException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceCloseableIterator<T>- Throws:
java.lang.RuntimeException
-
skipTo
public boolean skipTo(T e)
Description copied from interface:SkippingIteratorMoves the iterators position to the next element which is greater than or equal totheElement.- Specified by:
skipToin interfaceSkippingIterator<T>- Returns:
- true, if such an element exists (in which case the
Iterator.next()call will return it), false otherwise
-
skipTo
public boolean skipTo(T theElement, T theBound)
Description copied from interface:SkippingIteratorSame contract asSkippingIterator.skipTo(Object)but skipping is bounded: if the implementation can determine that the next element after target is greater than the bound, it can return false. In other words, if the method returns false, no element between the target (incl.) and the bound (incl.) exists. If the method returns true, the next element is definitely greater or equal than the target, but may exceed the bound. If the method returns false, there's no guarantee on the state of the iterator. If it needs to be reused, it must be first reset.- Specified by:
skipToin interfaceSkippingIterator<T>- Parameters:
theElement- the targettheBound- the bound. null means no upper bound.- Returns:
- true, if an element that is greater than or equal to
theElementbut less than or equal totheBoundexists.
-
comparator
public java.util.Comparator<T> comparator()
Description copied from interface:SkippingIteratorReturns the comparator for this iterator that specifies the order in which the elements are returned.- Specified by:
comparatorin interfaceSkippingIterator<T>
-
estimatedSize
public long estimatedSize()
Description copied from interface:SkippingIteratorReturns the estimated size of this iterator without advancing the iterator orSkippingIterator.UNKNOWN_SIZEif the estimate is not known. The estimate is for the whole iterator and will not change after the iterator is advanced. There is no guarantee about the accuracy of the estimate.- Specified by:
estimatedSizein interfaceSkippingIterator<T>
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<T>
-
-