Interface Spliterator.OfInt
- All Superinterfaces:
Spliterator<Integer>, Spliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>
- All Known Implementing Classes:
Spliterators.AbstractIntSpliterator
- Enclosing interface:
Spliterator<T>
int values.- Since:
- 1.8
-
Nested Class Summary
Nested classes/interfaces inherited from interface Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR> Modifier and TypeInterfaceDescriptionstatic interfaceA Spliterator specialized fordoublevalues.static interfaceA Spliterator specialized forintvalues.static interfaceA Spliterator specialized forlongvalues.static interfaceSpliterator.OfPrimitive<T, T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T,T_CONS, T_SPLITR>> A Spliterator specialized for primitive values. -
Field Summary
Fields inherited from interface Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZEDModifier and TypeFieldDescriptionstatic final intCharacteristic value signifying that the element source may be safely concurrently modified (allowing additions, replacements, and/or removals) by multiple threads without external synchronization.static final intCharacteristic value signifying that, for each pair of encountered elementsx, y,!x.equals(y).static final intCharacteristic value signifying that the element source cannot be structurally modified; that is, elements cannot be added, replaced, or removed, so such changes cannot occur during traversal.static final intCharacteristic value signifying that the source guarantees that encountered elements will not benull.static final intCharacteristic value signifying that an encounter order is defined for elements.static final intCharacteristic value signifying that the value returned fromestimateSize()prior to traversal or splitting represents a finite size that, in the absence of structural source modification, represents an exact count of the number of elements that would be encountered by a complete traversal.static final intCharacteristic value signifying that encounter order follows a defined sort order.static final intCharacteristic value signifying that all Spliterators resulting fromtrySplit()will be bothSpliterator.SIZEDandSpliterator.SUBSIZED. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidforEachRemaining(Consumer<? super Integer> action) Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.default voidforEachRemaining(IntConsumer action) Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.default booleantryAdvance(Consumer<? super Integer> action) If a remaining element exists: performs the given action on it, returningtrue; else returnsfalse.booleantryAdvance(IntConsumer action) If a remaining element exists, performs the given action on it, returningtrue; else returnsfalse.trySplit()If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.Methods inherited from interface Spliterator
characteristics, estimateSize, getComparator, getExactSizeIfKnown, hasCharacteristicsModifier and TypeMethodDescriptionintReturns a set of characteristics of this Spliterator and its elements.longReturns an estimate of the number of elements that would be encountered by aSpliterator.forEachRemaining(Consumer)traversal, or returnsLong.MAX_VALUEif infinite, unknown, or too expensive to compute.default Comparator<? super Integer> default longConvenience method that returnsSpliterator.estimateSize()if this Spliterator isSpliterator.SIZED, else-1.default booleanhasCharacteristics(int characteristics) Returnstrueif this Spliterator'sSpliterator.characteristics()contain all of the given characteristics.
-
Method Details
-
trySplit
Spliterator.OfInt trySplit()Description copied from interface:SpliteratorIf this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.If this Spliterator is
Spliterator.ORDERED, the returned Spliterator must cover a strict prefix of the elements.Unless this Spliterator covers an infinite number of elements, repeated calls to
trySplit()must eventually returnnull. Upon non-null return:- the value reported for
estimateSize()before splitting, must, after splitting, be greater than or equal toestimateSize()for this and the returned Spliterator; and - if this Spliterator is
SUBSIZED, thenestimateSize()for this spliterator before splitting must be equal to the sum ofestimateSize()for this and the returned Spliterator after splitting.
This method may return
nullfor any reason, including emptiness, inability to split after traversal has commenced, data structure constraints, and efficiency considerations.- Specified by:
trySplitin interfaceSpliterator<Integer>- Specified by:
trySplitin interfaceSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>- Returns:
- a
Spliteratorcovering some portion of the elements, ornullif this spliterator cannot be split
- the value reported for
-
tryAdvance
Description copied from interface:Spliterator.OfPrimitiveIf a remaining element exists, performs the given action on it, returningtrue; else returnsfalse. If this Spliterator isSpliterator.ORDEREDthe action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.Subsequent behavior of a spliterator is unspecified if the action throws an exception.
- Specified by:
tryAdvancein interfaceSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>- Parameters:
action- The action- Returns:
falseif no remaining elements existed upon entry to this method, elsetrue.
-
forEachRemaining
Description copied from interface:Spliterator.OfPrimitivePerforms the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception. If this Spliterator isSpliterator.ORDERED, actions are performed in encounter order. Exceptions thrown by the action are relayed to the caller.Subsequent behavior of a spliterator is unspecified if the action throws an exception.
- Specified by:
forEachRemainingin interfaceSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>- Parameters:
action- The action
-
tryAdvance
If a remaining element exists: performs the given action on it, returningtrue; else returnsfalse. If this Spliterator isSpliterator.ORDEREDthe action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.Subsequent behavior of a spliterator is unspecified if the action throws an exception.
- Specified by:
tryAdvancein interfaceSpliterator<Integer>- Implementation Requirements:
- If the action is an instance of
IntConsumerthen it is cast toIntConsumerand passed totryAdvance(java.util.function.IntConsumer); otherwise the action is adapted to an instance ofIntConsumer, by boxing the argument ofIntConsumer, and then passed totryAdvance(java.util.function.IntConsumer). - Parameters:
action- The action whose operation is performed at-most once- Returns:
falseif no remaining elements existed upon entry to this method, elsetrue.
-
forEachRemaining
Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception. If this Spliterator isSpliterator.ORDERED, actions are performed in encounter order. Exceptions thrown by the action are relayed to the caller.Subsequent behavior of a spliterator is unspecified if the action throws an exception.
- Specified by:
forEachRemainingin interfaceSpliterator<Integer>- Implementation Requirements:
- If the action is an instance of
IntConsumerthen it is cast toIntConsumerand passed toforEachRemaining(java.util.function.IntConsumer); otherwise the action is adapted to an instance ofIntConsumer, by boxing the argument ofIntConsumer, and then passed toforEachRemaining(java.util.function.IntConsumer). - Parameters:
action- The action
-