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 void
close()
java.util.Comparator<T>
comparator()
Returns the comparator for this iterator that specifies the order in which the elements are returned.long
estimatedSize()
Returns the estimated size of this iterator without advancing the iterator orSkippingIterator.UNKNOWN_SIZE
if the estimate is not known.boolean
hasNext()
T
next()
void
reset()
Resets the iterator to the beginning so the followingIterator.next()
call will return the first element in this iteration.T
skipTo(T e)
Returns the element which is equal or greater to theElement based on the ordering of the elements in the underlying data source, i.e., for two elements A, B s.t.-
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.collect.SkippingIterator
skipTo
-
-
-
-
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:ResettableIterator
Resets the iterator to the beginning so the followingIterator.next()
call will return the first element in this iteration.- Specified by:
reset
in interfaceResettableIterator<T>
-
close
public void close() throws java.lang.RuntimeException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceCloseableIterator<T>
- Throws:
java.lang.RuntimeException
-
skipTo
public T skipTo(T e)
Description copied from interface:SkippingIterator
Returns the element which is equal or greater to theElement based on the ordering of the elements in the underlying data source, i.e., for two elements A, B s.t. B comes after A during iteration, theComparator should returnA <= B
. Note that skips are always in the forward direction. iftheElement
compares to less than the last returned element (or less than the bounding start of the iterator), then no skip will occur, and the returned value is the same as if `next()` was called.- Specified by:
skipTo
in interfaceSkippingIterator<T>
- Returns:
- the smallest element
A
s.t.A <= theElement
, iftheElement > last seen element
, or the output ofnext()
if not.
-
comparator
public java.util.Comparator<T> comparator()
Description copied from interface:SkippingIterator
Returns the comparator for this iterator that specifies the order in which the elements are returned.- Specified by:
comparator
in interfaceSkippingIterator<T>
-
estimatedSize
public long estimatedSize()
Description copied from interface:SkippingIterator
Returns the estimated size of this iterator without advancing the iterator orSkippingIterator.UNKNOWN_SIZE
if 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:
estimatedSize
in interfaceSkippingIterator<T>
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<T>
-
-