Class Spliterators
Spliterator and its primitive specializations
Spliterator.OfInt, Spliterator.OfLong, and
Spliterator.OfDouble.- Since:
- 1.8
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classAn abstractSpliterator.OfDoublethat implementstrySplitto permit limited parallelism.static classAn abstractSpliterator.OfIntthat implementstrySplitto permit limited parallelism.static classAn abstractSpliterator.OfLongthat implementstrySplitto permit limited parallelism.static classAn abstractSpliteratorthat implementstrySplitto permit limited parallelism.
- 
Method SummaryModifier and TypeMethodDescriptionstatic Spliterator.OfDoubleCreates an emptySpliterator.OfDoublestatic Spliterator.OfIntCreates an emptySpliterator.OfIntstatic Spliterator.OfLongCreates an emptySpliterator.OfLongstatic <T> Spliterator<T> Creates an emptySpliteratorstatic PrimitiveIterator.OfDoubleiterator(Spliterator.OfDouble spliterator) Creates anPrimitiveIterator.OfDoublefrom aSpliterator.OfDouble.static PrimitiveIterator.OfIntiterator(Spliterator.OfInt spliterator) Creates anPrimitiveIterator.OfIntfrom aSpliterator.OfInt.static PrimitiveIterator.OfLongiterator(Spliterator.OfLong spliterator) Creates anPrimitiveIterator.OfLongfrom aSpliterator.OfLong.static <T> Iterator<T> iterator(Spliterator<? extends T> spliterator) Creates anIteratorfrom aSpliterator.static Spliterator.OfDoublespliterator(double[] array, int additionalCharacteristics) Creates aSpliterator.OfDoublecovering the elements of a given array, using a customized set of spliterator characteristics.static Spliterator.OfDoublespliterator(double[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliterator.OfDoublecovering a range of elements of a given array, using a customized set of spliterator characteristics.static Spliterator.OfIntspliterator(int[] array, int additionalCharacteristics) Creates aSpliterator.OfIntcovering the elements of a given array, using a customized set of spliterator characteristics.static Spliterator.OfIntspliterator(int[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliterator.OfIntcovering a range of elements of a given array, using a customized set of spliterator characteristics.static Spliterator.OfLongspliterator(long[] array, int additionalCharacteristics) Creates aSpliterator.OfLongcovering the elements of a given array, using a customized set of spliterator characteristics.static Spliterator.OfLongspliterator(long[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliterator.OfLongcovering a range of elements of a given array, using a customized set of spliterator characteristics.static <T> Spliterator<T> spliterator(Object[] array, int additionalCharacteristics) Creates aSpliteratorcovering the elements of a given array, using a customized set of spliterator characteristics.static <T> Spliterator<T> spliterator(Object[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliteratorcovering a range of elements of a given array, using a customized set of spliterator characteristics.static <T> Spliterator<T> spliterator(Collection<? extends T> c, int characteristics) static <T> Spliterator<T> spliterator(Iterator<? extends T> iterator, long size, int characteristics) Creates aSpliteratorusing a givenIteratoras the source of elements, and with a given initially reported size.static Spliterator.OfDoublespliterator(PrimitiveIterator.OfDouble iterator, long size, int characteristics) Creates aSpliterator.OfDoubleusing a givenDoubleStream.DoubleIteratoras the source of elements, and with a given initially reported size.static Spliterator.OfIntspliterator(PrimitiveIterator.OfInt iterator, long size, int characteristics) Creates aSpliterator.OfIntusing a givenIntStream.IntIteratoras the source of elements, and with a given initially reported size.static Spliterator.OfLongspliterator(PrimitiveIterator.OfLong iterator, long size, int characteristics) Creates aSpliterator.OfLongusing a givenLongStream.LongIteratoras the source of elements, and with a given initially reported size.static <T> Spliterator<T> spliteratorUnknownSize(Iterator<? extends T> iterator, int characteristics) Creates aSpliteratorusing a givenIteratoras the source of elements, with no initial size estimate.static Spliterator.OfDoublespliteratorUnknownSize(PrimitiveIterator.OfDouble iterator, int characteristics) Creates aSpliterator.OfDoubleusing a givenDoubleStream.DoubleIteratoras the source of elements, with no initial size estimate.static Spliterator.OfIntspliteratorUnknownSize(PrimitiveIterator.OfInt iterator, int characteristics) Creates aSpliterator.OfIntusing a givenIntStream.IntIteratoras the source of elements, with no initial size estimate.static Spliterator.OfLongspliteratorUnknownSize(PrimitiveIterator.OfLong iterator, int characteristics) Creates aSpliterator.OfLongusing a givenLongStream.LongIteratoras the source of elements, with no initial size estimate.
- 
Method Details- 
emptySpliteratorCreates an emptySpliteratorThe empty spliterator reports Spliterator.SIZEDandSpliterator.SUBSIZED. Calls toSpliterator.trySplit()always returnnull.- Type Parameters:
- T- Type of elements
- Returns:
- An empty spliterator
 
- 
emptyIntSpliteratorCreates an emptySpliterator.OfIntThe empty spliterator reports Spliterator.SIZEDandSpliterator.SUBSIZED. Calls toSpliterator.trySplit()always returnnull.- Returns:
- An empty spliterator
 
- 
emptyLongSpliteratorCreates an emptySpliterator.OfLongThe empty spliterator reports Spliterator.SIZEDandSpliterator.SUBSIZED. Calls toSpliterator.trySplit()always returnnull.- Returns:
- An empty spliterator
 
- 
emptyDoubleSpliteratorCreates an emptySpliterator.OfDoubleThe empty spliterator reports Spliterator.SIZEDandSpliterator.SUBSIZED. Calls toSpliterator.trySplit()always returnnull.- Returns:
- An empty spliterator
 
- 
spliteratorCreates aSpliteratorcovering the elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(Object[]).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specifyIMMUTABLEandORDERED.- Type Parameters:
- T- Type of elements
- Parameters:
- array- The array, assumed to be unmodified during use
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- See Also:
 
- 
spliteratorpublic static <T> Spliterator<T> spliterator(Object[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliteratorcovering a range of elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(Object[]).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specifyIMMUTABLEandORDERED.- Type Parameters:
- T- Type of elements
- Parameters:
- array- The array, assumed to be unmodified during use
- fromIndex- The least index (inclusive) to cover
- toIndex- One past the greatest index to cover
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- ArrayIndexOutOfBoundsException- if- fromIndexis negative,- toIndexis less than- fromIndex, or- toIndexis greater than the array size
- See Also:
 
- 
spliteratorCreates aSpliterator.OfIntcovering the elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(int[]).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specifyIMMUTABLEandORDERED.- Parameters:
- array- The array, assumed to be unmodified during use
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- See Also:
 
- 
spliteratorpublic static Spliterator.OfInt spliterator(int[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliterator.OfIntcovering a range of elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(int[], int, int).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specifyIMMUTABLEandORDERED.- Parameters:
- array- The array, assumed to be unmodified during use
- fromIndex- The least index (inclusive) to cover
- toIndex- One past the greatest index to cover
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- ArrayIndexOutOfBoundsException- if- fromIndexis negative,- toIndexis less than- fromIndex, or- toIndexis greater than the array size
- See Also:
 
- 
spliteratorCreates aSpliterator.OfLongcovering the elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(long[]).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specifyIMMUTABLEandORDERED.- Parameters:
- array- The array, assumed to be unmodified during use
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- See Also:
 
- 
spliteratorpublic static Spliterator.OfLong spliterator(long[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliterator.OfLongcovering a range of elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(long[], int, int).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report. (For example, if it is known the array will not be further modified, specifyIMMUTABLE; if the array data is considered to have an encounter order, specifyORDERED). The methodArrays.spliterator(long[], int, int)can often be used instead, which returns a spliterator that reportsSIZED,SUBSIZED,IMMUTABLE, andORDERED.- Parameters:
- array- The array, assumed to be unmodified during use
- fromIndex- The least index (inclusive) to cover
- toIndex- One past the greatest index to cover
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- ArrayIndexOutOfBoundsException- if- fromIndexis negative,- toIndexis less than- fromIndex, or- toIndexis greater than the array size
- See Also:
 
- 
spliteratorCreates aSpliterator.OfDoublecovering the elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(double[]).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specifyIMMUTABLEandORDERED.- Parameters:
- array- The array, assumed to be unmodified during use
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- See Also:
 
- 
spliteratorpublic static Spliterator.OfDouble spliterator(double[] array, int fromIndex, int toIndex, int additionalCharacteristics) Creates aSpliterator.OfDoublecovering a range of elements of a given array, using a customized set of spliterator characteristics.This method is provided as an implementation convenience for Spliterators which store portions of their elements in arrays, and need fine control over Spliterator characteristics. Most other situations in which a Spliterator for an array is needed should use Arrays.spliterator(double[], int, int).The returned spliterator always reports the characteristics SIZEDandSUBSIZED. The caller may provide additional characteristics for the spliterator to report. (For example, if it is known the array will not be further modified, specifyIMMUTABLE; if the array data is considered to have an encounter order, specifyORDERED). The methodArrays.spliterator(long[], int, int)can often be used instead, which returns a spliterator that reportsSIZED,SUBSIZED,IMMUTABLE, andORDERED.- Parameters:
- array- The array, assumed to be unmodified during use
- fromIndex- The least index (inclusive) to cover
- toIndex- One past the greatest index to cover
- additionalCharacteristics- Additional spliterator characteristics of this spliterator's source or elements beyond- SIZEDand- SUBSIZEDwhich are always reported
- Returns:
- A spliterator for an array
- Throws:
- NullPointerException- if the given array is- null
- ArrayIndexOutOfBoundsException- if- fromIndexis negative,- toIndexis less than- fromIndex, or- toIndexis greater than the array size
- See Also:
 
- 
spliteratorCreates aSpliteratorusing the given collection'siteratoras the source of elements, and reporting itssizeas its initial size.The spliterator is late-binding, inherits the fail-fast properties of the collection's iterator, and implements trySplitto permit limited parallelism.- Type Parameters:
- T- Type of elements
- Parameters:
- c- The collection
- characteristics- Characteristics of this spliterator's source or elements. The characteristics- SIZEDand- SUBSIZEDare additionally reported unless- CONCURRENTis supplied.
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given collection is- null
 
- 
spliteratorpublic static <T> Spliterator<T> spliterator(Iterator<? extends T> iterator, long size, int characteristics) Creates aSpliteratorusing a givenIteratoras the source of elements, and with a given initially reported size.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned, or the initially reported size is not equal to the actual number of elements in the source. - Type Parameters:
- T- Type of elements
- Parameters:
- iterator- The iterator for the source
- size- The number of elements in the source, to be reported as initial- estimateSize
- characteristics- Characteristics of this spliterator's source or elements. The characteristics- SIZEDand- SUBSIZEDare additionally reported unless- CONCURRENTis supplied.
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorUnknownSizepublic static <T> Spliterator<T> spliteratorUnknownSize(Iterator<? extends T> iterator, int characteristics) Creates aSpliteratorusing a givenIteratoras the source of elements, with no initial size estimate.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned. - Type Parameters:
- T- Type of elements
- Parameters:
- iterator- The iterator for the source
- characteristics- Characteristics of this spliterator's source or elements (- SIZEDand- SUBSIZED, if supplied, are ignored and are not reported.)
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorpublic static Spliterator.OfInt spliterator(PrimitiveIterator.OfInt iterator, long size, int characteristics) Creates aSpliterator.OfIntusing a givenIntStream.IntIteratoras the source of elements, and with a given initially reported size.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned, or the initially reported size is not equal to the actual number of elements in the source. - Parameters:
- iterator- The iterator for the source
- size- The number of elements in the source, to be reported as initial- estimateSize.
- characteristics- Characteristics of this spliterator's source or elements. The characteristics- SIZEDand- SUBSIZEDare additionally reported unless- CONCURRENTis supplied.
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorUnknownSizepublic static Spliterator.OfInt spliteratorUnknownSize(PrimitiveIterator.OfInt iterator, int characteristics) Creates aSpliterator.OfIntusing a givenIntStream.IntIteratoras the source of elements, with no initial size estimate.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned. - Parameters:
- iterator- The iterator for the source
- characteristics- Characteristics of this spliterator's source or elements (- SIZEDand- SUBSIZED, if supplied, are ignored and are not reported.)
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorpublic static Spliterator.OfLong spliterator(PrimitiveIterator.OfLong iterator, long size, int characteristics) Creates aSpliterator.OfLongusing a givenLongStream.LongIteratoras the source of elements, and with a given initially reported size.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned, or the initially reported size is not equal to the actual number of elements in the source. - Parameters:
- iterator- The iterator for the source
- size- The number of elements in the source, to be reported as initial- estimateSize.
- characteristics- Characteristics of this spliterator's source or elements. The characteristics- SIZEDand- SUBSIZEDare additionally reported unless- CONCURRENTis supplied.
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorUnknownSizepublic static Spliterator.OfLong spliteratorUnknownSize(PrimitiveIterator.OfLong iterator, int characteristics) Creates aSpliterator.OfLongusing a givenLongStream.LongIteratoras the source of elements, with no initial size estimate.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned. - Parameters:
- iterator- The iterator for the source
- characteristics- Characteristics of this spliterator's source or elements (- SIZEDand- SUBSIZED, if supplied, are ignored and are not reported.)
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorpublic static Spliterator.OfDouble spliterator(PrimitiveIterator.OfDouble iterator, long size, int characteristics) Creates aSpliterator.OfDoubleusing a givenDoubleStream.DoubleIteratoras the source of elements, and with a given initially reported size.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned, or the initially reported size is not equal to the actual number of elements in the source. - Parameters:
- iterator- The iterator for the source
- size- The number of elements in the source, to be reported as initial- estimateSize
- characteristics- Characteristics of this spliterator's source or elements. The characteristics- SIZEDand- SUBSIZEDare additionally reported unless- CONCURRENTis supplied.
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
spliteratorUnknownSizepublic static Spliterator.OfDouble spliteratorUnknownSize(PrimitiveIterator.OfDouble iterator, int characteristics) Creates aSpliterator.OfDoubleusing a givenDoubleStream.DoubleIteratoras the source of elements, with no initial size estimate.The spliterator is not late-binding, inherits the fail-fast properties of the iterator, and implements trySplitto permit limited parallelism.Traversal of elements should be accomplished through the spliterator. The behaviour of splitting and traversal is undefined if the iterator is operated on after the spliterator is returned. - Parameters:
- iterator- The iterator for the source
- characteristics- Characteristics of this spliterator's source or elements (- SIZEDand- SUBSIZED, if supplied, are ignored and are not reported.)
- Returns:
- A spliterator from an iterator
- Throws:
- NullPointerException- if the given iterator is- null
 
- 
iteratorCreates anIteratorfrom aSpliterator.Traversal of elements should be accomplished through the iterator. The behaviour of traversal is undefined if the spliterator is operated after the iterator is returned. - Type Parameters:
- T- Type of elements
- Parameters:
- spliterator- The spliterator
- Returns:
- An iterator
- Throws:
- NullPointerException- if the given spliterator is- null
 
- 
iteratorCreates anPrimitiveIterator.OfIntfrom aSpliterator.OfInt.Traversal of elements should be accomplished through the iterator. The behaviour of traversal is undefined if the spliterator is operated after the iterator is returned. - Parameters:
- spliterator- The spliterator
- Returns:
- An iterator
- Throws:
- NullPointerException- if the given spliterator is- null
 
- 
iteratorCreates anPrimitiveIterator.OfLongfrom aSpliterator.OfLong.Traversal of elements should be accomplished through the iterator. The behaviour of traversal is undefined if the spliterator is operated after the iterator is returned. - Parameters:
- spliterator- The spliterator
- Returns:
- An iterator
- Throws:
- NullPointerException- if the given spliterator is- null
 
- 
iteratorCreates anPrimitiveIterator.OfDoublefrom aSpliterator.OfDouble.Traversal of elements should be accomplished through the iterator. The behaviour of traversal is undefined if the spliterator is operated after the iterator is returned. - Parameters:
- spliterator- The spliterator
- Returns:
- An iterator
- Throws:
- NullPointerException- if the given spliterator is- null
 
 
-