Interface RowSet.SearchIterator
- All Superinterfaces:
AutoCloseable
,Iterator<Long>
,PrimitiveIterator<Long,
,LongConsumer> PrimitiveIterator.OfLong
,RowSet.Iterator
,SafeCloseable
- Enclosing interface:
- RowSet
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.PrimitiveIterator
PrimitiveIterator.OfDouble, PrimitiveIterator.OfInt, PrimitiveIterator.OfLong
-
Method Summary
Modifier and TypeMethodDescriptionboolean
advance
(long v) Advance the current iterator position untilcurrentValue()
is greater than or equal to `v`.long
binarySearchValue
(RowSet.TargetComparator comp, int dir) Advance the current iterator (start) position while the current value maintains comp.compareTargetTo(v, dir) > 0.long
Methods inherited from interface java.util.PrimitiveIterator.OfLong
forEachRemaining, forEachRemaining, next, nextLong
Methods inherited from interface io.deephaven.engine.rowset.RowSet.Iterator
forEachLong
Methods inherited from interface io.deephaven.util.SafeCloseable
close
-
Method Details
-
currentValue
long currentValue() -
advance
boolean advance(long v) Advance the current iterator position until
currentValue()
is greater than or equal to `v`. The operation is a no-op (and returns true) if currentValue() is already >= 'v'. Returns true if the operation was successful. Otherwise, returns false. In this case the iteration is over and the iterator is exhausted; calls tohasNext()
will return false, any other operation is undefined.Although calls to
advance()
may be interleaved with calls tohasNext()
/next()
if necessary, this is not the common case, as they are separate protocols having little to do with each other. In particular, when iterating withadvance()
, you do not use next() to bring the value you advanced to into view, even at the start of the iteration. Many common usages only involve calls to advance().- Parameters:
v
- a value to search forward from the current iterator position- Returns:
- false if iteration is exhausted, otherwise true.
-
binarySearchValue
Advance the current iterator (start) position while the current value maintains comp.compareTargetTo(v, dir) > 0. If next to the last such value there is a value for which comp.compareTargetTo(v, dir) < 0, or no further values exist, then that last value satisfying comp,.compareTargetTo(v, dir) > 0 is left as the current position and returned. If there are any elements for which comp.compareTargetTo(v, dir) == 0, one of such elements, no guarantee which one, is left as the current position and returned. If at call entry the iterator was exhausted, -1 is returned. If at call entry the iterator was just constructed and had never been advanced, it is moved to the first element (which becomes the current value). If the current value v is such that comp.compareTargetTo(v, dir) < 0, -1 is returned and the current position is not moved.
Part of the contract of this method is that comp.compareTargetTo will only be called with values that are in the underlying container.
- Parameters:
comp
- a comparator used to search forward from the current iterator positiondir
- a direction to search for comp, either +1 for forward or -1 for backward.- Returns:
- -1 if the iterator was exhausted at entry or the target was to the left of the initial position at the time of the call, in which case the iterator is not changed; the resulting current position otherwise. In this later case the current position is guaranteed to satisfy comp.compareTargetTo(v, dir) >= 0 and if also comp.compareTargetTo(v, dir) > 0, then v is the biggest such value for which comp.compareTargetTo(v, dir) > 0.
-