Class IntegerList.PrimitiveSpliterator
java.lang.Object
org.apache.sis.util.collection.IntegerList.PrimitiveSpliterator
- All Implemented Interfaces:
Iterator<Integer>, PrimitiveIterator<Integer, IntConsumer>, PrimitiveIterator.OfInt, Spliterator<Integer>, Spliterator.OfInt, Spliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>
- Enclosing class:
IntegerList
private final class IntegerList.PrimitiveSpliterator
extends Object
implements Spliterator.OfInt, PrimitiveIterator.OfInt
Same as
IntegerList.spliterator(), but without value boxing.
This spliterator provides a fail-fast way to traverse list content, which means
that any alteration to the list content causes a failure of the advance operation
with a ConcurrentModificationException.
This implementation opportunistically provides an iterator implementation on
integer values too, but only one of the Iterator or Spliterator
API should be used on a given instance.
- Since:
- 0.7
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface PrimitiveIterator
PrimitiveIterator.OfDouble, PrimitiveIterator.OfInt, PrimitiveIterator.OfLongNested classes/interfaces inherited from interface Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intTheAbstractList.modCountvalue as iterator construction time.private intIndex of the last elements removed by aremove()operation.private intIndex of the next element to be returned.private intIndex after the last element returned by this spliterator.Fields inherited from interface Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Creates a new iterator for the whole content of the backing list.privatePrimitiveSpliterator(IntegerList.PrimitiveSpliterator suffix, int startAt) Creates the prefix spliterator in a call totrySplit(). -
Method Summary
Modifier and TypeMethodDescriptionintDeclares that this split iterator does not return null elements, that all elements are traversed in a fixed order (which is increasing index values) and thatIntegerList.size()represents an exact count of elements.longReturns the exact number of values to be encountered by aforEachRemaining(…)traversal.voidforEachRemaining(Consumer<? super Integer> action) Performs the given action on all remaining elements.voidforEachRemaining(IntConsumer action) Performs the given action on all remaining elements.booleanhasNext()Returnstrueif there is one more value to return.intnextInt()Returns the next integer values in iterator order.voidremove()Removes the last element returned bynextInt().booleantryAdvance(IntConsumer action) If a remaining element exists, performs the given action on it and returnstrue.trySplit()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PrimitiveIterator.OfInt
nextMethods inherited from interface Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristicsMethods inherited from interface Spliterator.OfInt
tryAdvance
-
Field Details
-
stopAt
private int stopAtIndex after the last element returned by this spliterator. This is initiallyIntegerList.size, but may be set to a smaller value by call totrySplit(). -
nextIndex
private int nextIndexIndex of the next element to be returned. -
expectedModCount
private int expectedModCountTheAbstractList.modCountvalue as iterator construction time. Used for detecting modification in the backing list during traversal. -
lastRemove
private int lastRemoveIndex of the last elements removed by aremove()operation. This is used for checking thatremove()is not invoked twice before the next advance.
-
-
Constructor Details
-
PrimitiveSpliterator
PrimitiveSpliterator()Creates a new iterator for the whole content of the backing list. -
PrimitiveSpliterator
Creates the prefix spliterator in a call totrySplit().- Parameters:
suffix- the spliterator which will continue iteration after this spliterator.startAt- index of the first element to be returned by this prefix spliterator.
-
-
Method Details
-
characteristics
public int characteristics()Declares that this split iterator does not return null elements, that all elements are traversed in a fixed order (which is increasing index values) and thatIntegerList.size()represents an exact count of elements.- Specified by:
characteristicsin interfaceSpliterator<Integer>
-
estimateSize
public long estimateSize()Returns the exact number of values to be encountered by aforEachRemaining(…)traversal.- Specified by:
estimateSizein interfaceSpliterator<Integer>
-
trySplit
- Specified by:
trySplitin interfaceSpliterator<Integer>- Specified by:
trySplitin interfaceSpliterator.OfInt- Specified by:
trySplitin interfaceSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>
-
hasNext
-
nextInt
public int nextInt()Returns the next integer values in iterator order.- Specified by:
nextIntin interfacePrimitiveIterator.OfInt
-
tryAdvance
If a remaining element exists, performs the given action on it and returnstrue. Otherwise returnsfalse.- Specified by:
tryAdvancein interfaceSpliterator.OfInt- Specified by:
tryAdvancein interfaceSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>
-
forEachRemaining
Performs the given action on all remaining elements. This implementation is shared by bothIteratorandSpliteratorinterfaces.- Specified by:
forEachRemainingin interfacePrimitiveIterator<Integer, IntConsumer>- Specified by:
forEachRemainingin interfacePrimitiveIterator.OfInt- Specified by:
forEachRemainingin interfaceSpliterator.OfInt- Specified by:
forEachRemainingin interfaceSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>
-
forEachRemaining
Performs the given action on all remaining elements. This implementation is shared by bothIteratorandSpliteratorinterfaces.- Specified by:
forEachRemainingin interfaceIterator<Integer>- Specified by:
forEachRemainingin interfacePrimitiveIterator.OfInt- Specified by:
forEachRemainingin interfaceSpliterator<Integer>- Specified by:
forEachRemainingin interfaceSpliterator.OfInt
-
remove
-