Spliterators

public final class Spliterators
extends Object

java.lang.Object
   ↳ java.util.Spliterators


Static classes and methods for operating on or creating instances of Spliterator and its primitive specializations Spliterator.OfInt, Spliterator.OfLong, and Spliterator.OfDouble.

See also:

Summary

Nested classes

class Spliterators.AbstractDoubleSpliterator

An abstract Spliterator.OfDouble that implements trySplit to permit limited parallelism. 

class Spliterators.AbstractIntSpliterator

An abstract Spliterator.OfInt that implements trySplit to permit limited parallelism. 

class Spliterators.AbstractLongSpliterator

An abstract Spliterator.OfLong that implements trySplit to permit limited parallelism. 

class Spliterators.AbstractSpliterator<T>

An abstract Spliterator that implements trySplit to permit limited parallelism. 

Public methods

static Spliterator.OfDouble emptyDoubleSpliterator()

Creates an empty Spliterator.OfDouble

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED.

static Spliterator.OfInt emptyIntSpliterator()

Creates an empty Spliterator.OfInt

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED.

static Spliterator.OfLong emptyLongSpliterator()

Creates an empty Spliterator.OfLong

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED.

static <T> Spliterator<T> emptySpliterator()

Creates an empty Spliterator

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED.

static PrimitiveIterator.OfDouble iterator(Spliterator.OfDouble spliterator)

Creates an PrimitiveIterator.OfDouble from a Spliterator.OfDouble.

static PrimitiveIterator.OfInt iterator(Spliterator.OfInt spliterator)

Creates an PrimitiveIterator.OfInt from a Spliterator.OfInt.

static PrimitiveIterator.OfLong iterator(Spliterator.OfLong spliterator)

Creates an PrimitiveIterator.OfLong from a Spliterator.OfLong.

static <T> Iterator<T> iterator(Spliterator<? extends T> spliterator)

Creates an Iterator from a Spliterator.

static <T> Spliterator<T> spliterator(Iterator<? extends T> iterator, long size, int characteristics)

Creates a Spliterator using a given Iterator as the source of elements, and with a given initially reported size.

static Spliterator.OfLong spliterator(long[] array, int additionalCharacteristics)

Creates a Spliterator.OfLong covering 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 a Spliterator covering a range of elements of a given array, using a customized set of spliterator characteristics.

static Spliterator.OfLong spliterator(long[] array, int fromIndex, int toIndex, int additionalCharacteristics)

Creates a Spliterator.OfLong covering a range of elements of a given array, using a customized set of spliterator characteristics.

static Spliterator.OfLong spliterator(PrimitiveIterator.OfLong iterator, long size, int characteristics)

Creates a Spliterator.OfLong using a given LongStream.LongIterator as the source of elements, and with a given initially reported size.

static Spliterator.OfDouble spliterator(PrimitiveIterator.OfDouble iterator, long size, int characteristics)

Creates a Spliterator.OfDouble using a given DoubleStream.DoubleIterator as the source of elements, and with a given initially reported size.

static Spliterator.OfDouble spliterator(double[] array, int additionalCharacteristics)

Creates a Spliterator.OfDouble covering the elements of a given array, using a customized set of spliterator characteristics.

static Spliterator.OfInt spliterator(int[] array, int fromIndex, int toIndex, int additionalCharacteristics)

Creates a Spliterator.OfInt covering 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)

Creates a Spliterator using the given collection's Collection.iterator() as the source of elements, and reporting its Collection.size() as its initial size.

static <T> Spliterator<T> spliterator(Object[] array, int additionalCharacteristics)

Creates a Spliterator covering the elements of a given array, using a customized set of spliterator characteristics.

static Spliterator.OfInt spliterator(int[] array, int additionalCharacteristics)

Creates a Spliterator.OfInt covering the elements of a given array, using a customized set of spliterator characteristics.

static Spliterator.OfDouble spliterator(double[] array, int fromIndex, int toIndex, int additionalCharacteristics)

Creates a Spliterator.OfDouble covering a range of elements of a given array, using a customized set of spliterator characteristics.

static Spliterator.OfInt spliterator(PrimitiveIterator.OfInt iterator, long size, int characteristics)

Creates a Spliterator.OfInt using a given IntStream.IntIterator as the source of elements, and with a given initially reported size.

static Spliterator.OfInt spliteratorUnknownSize(PrimitiveIterator.OfInt iterator, int characteristics)

Creates a Spliterator.OfInt using a given IntStream.IntIterator as the source of elements, with no initial size estimate.

static <T> Spliterator<T> spliteratorUnknownSize(Iterator<? extends T> iterator, int characteristics)

Creates a Spliterator using a given Iterator as the source of elements, with no initial size estimate.

static Spliterator.OfDouble spliteratorUnknownSize(PrimitiveIterator.OfDouble iterator, int characteristics)

Creates a Spliterator.OfDouble using a given DoubleStream.DoubleIterator as the source of elements, with no initial size estimate.

static Spliterator.OfLong spliteratorUnknownSize(PrimitiveIterator.OfLong iterator, int characteristics)

Creates a Spliterator.OfLong using a given LongStream.LongIterator as the source of elements, with no initial size estimate.

Inherited methods

Public methods

emptyDoubleSpliterator

Added in API level 24
public static Spliterator.OfDouble emptyDoubleSpliterator ()

Creates an empty Spliterator.OfDouble

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED. Calls to Spliterator.trySplit() always return null.

Returns
Spliterator.OfDouble An empty spliterator

emptyIntSpliterator

Added in API level 24
public static Spliterator.OfInt emptyIntSpliterator ()

Creates an empty Spliterator.OfInt

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED. Calls to Spliterator.trySplit() always return null.

Returns
Spliterator.OfInt An empty spliterator

emptyLongSpliterator

Added in API level 24
public static Spliterator.OfLong emptyLongSpliterator ()

Creates an empty Spliterator.OfLong

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED. Calls to Spliterator.trySplit() always return null.

Returns
Spliterator.OfLong An empty spliterator

emptySpliterator

Added in API level 24
public static Spliterator<T> emptySpliterator ()

Creates an empty Spliterator

The empty spliterator reports Spliterator#SIZED and Spliterator#SUBSIZED. Calls to Spliterator.trySplit() always return null.

Returns
Spliterator<T> An empty spliterator

iterator

Added in API level 24
public static PrimitiveIterator.OfDouble iterator (Spliterator.OfDouble spliterator)

Creates an PrimitiveIterator.OfDouble from a Spliterator.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 Spliterator.OfDouble: The spliterator

Returns
PrimitiveIterator.OfDouble An iterator

Throws
NullPointerException if the given spliterator is null

iterator

Added in API level 24
public static PrimitiveIterator.OfInt iterator (Spliterator.OfInt spliterator)

Creates an PrimitiveIterator.OfInt from a Spliterator.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 Spliterator.OfInt: The spliterator

Returns
PrimitiveIterator.OfInt An iterator

Throws
NullPointerException if the given spliterator is null

iterator

Added in API level 24
public static PrimitiveIterator.OfLong iterator (Spliterator.OfLong spliterator)

Creates an PrimitiveIterator.OfLong from a Spliterator.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 Spliterator.OfLong: The spliterator

Returns
PrimitiveIterator.OfLong An iterator

Throws
NullPointerException if the given spliterator is null

iterator

Added in API level 24
public static Iterator<T> iterator (Spliterator<? extends T> spliterator)

Creates an Iterator from a Spliterator.

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 Spliterator: The spliterator

Returns
Iterator<T> An iterator

Throws
NullPointerException if the given spliterator is null

spliterator

Added in API level 24
public static Spliterator<T> spliterator (Iterator<? extends T> iterator, 
                long size, 
                int characteristics)

Creates a Spliterator using a given Iterator as 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 trySplit to 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 Iterator: The iterator for the source

size long: The number of elements in the source, to be reported as initial estimateSize

characteristics int: Characteristics of this spliterator's source or elements. The characteristics SIZED and SUBSIZED are additionally reported unless CONCURRENT is supplied.

Returns
Spliterator<T> A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliterator

Added in API level 24
public static Spliterator.OfLong spliterator (long[] array, 
                int additionalCharacteristics)

Creates a Spliterator.OfLong covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
array long: The array, assumed to be unmodified during use

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator.OfLong A spliterator for an array

Throws
NullPointerException if the given array is null

spliterator

Added in API level 24
public static Spliterator<T> spliterator (Object[] array, 
                int fromIndex, 
                int toIndex, 
                int additionalCharacteristics)

Creates a Spliterator covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
array Object: The array, assumed to be unmodified during use

fromIndex int: The least index (inclusive) to cover

toIndex int: One past the greatest index to cover

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator<T> A spliterator for an array

Throws
NullPointerException if the given array is null
ArrayIndexOutOfBoundsException if fromIndex is negative, toIndex is less than fromIndex, or toIndex is greater than the array size

spliterator

Added in API level 24
public static Spliterator.OfLong spliterator (long[] array, 
                int fromIndex, 
                int toIndex, 
                int additionalCharacteristics)

Creates a Spliterator.OfLong covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report. (For example, if it is known the array will not be further modified, specify IMMUTABLE; if the array data is considered to have an encounter order, specify ORDERED). The method Arrays#spliterator(long[], int, int) can often be used instead, which returns a spliterator that reports SIZED, SUBSIZED, IMMUTABLE, and ORDERED.

Parameters
array long: The array, assumed to be unmodified during use

fromIndex int: The least index (inclusive) to cover

toIndex int: One past the greatest index to cover

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator.OfLong A spliterator for an array

Throws
NullPointerException if the given array is null
ArrayIndexOutOfBoundsException if fromIndex is negative, toIndex is less than fromIndex, or toIndex is greater than the array size

spliterator

Added in API level 24
public static Spliterator.OfLong spliterator (PrimitiveIterator.OfLong iterator, 
                long size, 
                int characteristics)

Creates a Spliterator.OfLong using a given LongStream.LongIterator as 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 trySplit to 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 PrimitiveIterator.OfLong: The iterator for the source

size long: The number of elements in the source, to be reported as initial estimateSize.

characteristics int: Characteristics of this spliterator's source or elements. The characteristics SIZED and SUBSIZED are additionally reported unless CONCURRENT is supplied.

Returns
Spliterator.OfLong A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliterator

Added in API level 24
public static Spliterator.OfDouble spliterator (PrimitiveIterator.OfDouble iterator, 
                long size, 
                int characteristics)

Creates a Spliterator.OfDouble using a given DoubleStream.DoubleIterator as 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 trySplit to 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 PrimitiveIterator.OfDouble: The iterator for the source

size long: The number of elements in the source, to be reported as initial estimateSize

characteristics int: Characteristics of this spliterator's source or elements. The characteristics SIZED and SUBSIZED are additionally reported unless CONCURRENT is supplied.

Returns
Spliterator.OfDouble A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliterator

Added in API level 24
public static Spliterator.OfDouble spliterator (double[] array, 
                int additionalCharacteristics)

Creates a Spliterator.OfDouble covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
array double: The array, assumed to be unmodified during use

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator.OfDouble A spliterator for an array

Throws
NullPointerException if the given array is null

spliterator

Added in API level 24
public static Spliterator.OfInt spliterator (int[] array, 
                int fromIndex, 
                int toIndex, 
                int additionalCharacteristics)

Creates a Spliterator.OfInt covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
array int: The array, assumed to be unmodified during use

fromIndex int: The least index (inclusive) to cover

toIndex int: One past the greatest index to cover

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator.OfInt A spliterator for an array

Throws
NullPointerException if the given array is null
ArrayIndexOutOfBoundsException if fromIndex is negative, toIndex is less than fromIndex, or toIndex is greater than the array size

spliterator

Added in API level 24
public static Spliterator<T> spliterator (Collection<? extends T> c, 
                int characteristics)

Creates a Spliterator using the given collection's Collection.iterator() as the source of elements, and reporting its Collection.size() as its initial size.

The spliterator is late-binding, inherits the fail-fast properties of the collection's iterator, and implements trySplit to permit limited parallelism.

Parameters
c Collection: The collection

characteristics int: Characteristics of this spliterator's source or elements. The characteristics SIZED and SUBSIZED are additionally reported unless CONCURRENT is supplied.

Returns
Spliterator<T> A spliterator from an iterator

Throws
NullPointerException if the given collection is null

spliterator

Added in API level 24
public static Spliterator<T> spliterator (Object[] array, 
                int additionalCharacteristics)

Creates a Spliterator covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
array Object: The array, assumed to be unmodified during use

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator<T> A spliterator for an array

Throws
NullPointerException if the given array is null

spliterator

Added in API level 24
public static Spliterator.OfInt spliterator (int[] array, 
                int additionalCharacteristics)

Creates a Spliterator.OfInt covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report; it is common to additionally specify IMMUTABLE and ORDERED.

Parameters
array int: The array, assumed to be unmodified during use

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator.OfInt A spliterator for an array

Throws
NullPointerException if the given array is null

spliterator

Added in API level 24
public static Spliterator.OfDouble spliterator (double[] array, 
                int fromIndex, 
                int toIndex, 
                int additionalCharacteristics)

Creates a Spliterator.OfDouble covering 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 SIZED and SUBSIZED. The caller may provide additional characteristics for the spliterator to report. (For example, if it is known the array will not be further modified, specify IMMUTABLE; if the array data is considered to have an encounter order, specify ORDERED). The method Arrays#spliterator(long[], int, int) can often be used instead, which returns a spliterator that reports SIZED, SUBSIZED, IMMUTABLE, and ORDERED.

Parameters
array double: The array, assumed to be unmodified during use

fromIndex int: The least index (inclusive) to cover

toIndex int: One past the greatest index to cover

additionalCharacteristics int: Additional spliterator characteristics of this spliterator's source or elements beyond SIZED and SUBSIZED which are always reported

Returns
Spliterator.OfDouble A spliterator for an array

Throws
NullPointerException if the given array is null
ArrayIndexOutOfBoundsException if fromIndex is negative, toIndex is less than fromIndex, or toIndex is greater than the array size

spliterator

Added in API level 24
public static Spliterator.OfInt spliterator (PrimitiveIterator.OfInt iterator, 
                long size, 
                int characteristics)

Creates a Spliterator.OfInt using a given IntStream.IntIterator as 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 trySplit to 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 PrimitiveIterator.OfInt: The iterator for the source

size long: The number of elements in the source, to be reported as initial estimateSize.

characteristics int: Characteristics of this spliterator's source or elements. The characteristics SIZED and SUBSIZED are additionally reported unless CONCURRENT is supplied.

Returns
Spliterator.OfInt A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliteratorUnknownSize

Added in API level 24
public static Spliterator.OfInt spliteratorUnknownSize (PrimitiveIterator.OfInt iterator, 
                int characteristics)

Creates a Spliterator.OfInt using a given IntStream.IntIterator as 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 trySplit to 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 PrimitiveIterator.OfInt: The iterator for the source

characteristics int: Characteristics of this spliterator's source or elements (SIZED and SUBSIZED, if supplied, are ignored and are not reported.)

Returns
Spliterator.OfInt A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliteratorUnknownSize

Added in API level 24
public static Spliterator<T> spliteratorUnknownSize (Iterator<? extends T> iterator, 
                int characteristics)

Creates a Spliterator using a given Iterator as 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 trySplit to 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 Iterator: The iterator for the source

characteristics int: Characteristics of this spliterator's source or elements (SIZED and SUBSIZED, if supplied, are ignored and are not reported.)

Returns
Spliterator<T> A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliteratorUnknownSize

Added in API level 24
public static Spliterator.OfDouble spliteratorUnknownSize (PrimitiveIterator.OfDouble iterator, 
                int characteristics)

Creates a Spliterator.OfDouble using a given DoubleStream.DoubleIterator as 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 trySplit to 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 PrimitiveIterator.OfDouble: The iterator for the source

characteristics int: Characteristics of this spliterator's source or elements (SIZED and SUBSIZED, if supplied, are ignored and are not reported.)

Returns
Spliterator.OfDouble A spliterator from an iterator

Throws
NullPointerException if the given iterator is null

spliteratorUnknownSize

Added in API level 24
public static Spliterator.OfLong spliteratorUnknownSize (PrimitiveIterator.OfLong iterator, 
                int characteristics)

Creates a Spliterator.OfLong using a given LongStream.LongIterator as 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 trySplit to 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 PrimitiveIterator.OfLong: The iterator for the source

characteristics int: Characteristics of this spliterator's source or elements (SIZED and SUBSIZED, if supplied, are ignored and are not reported.)

Returns
Spliterator.OfLong A spliterator from an iterator

Throws
NullPointerException if the given iterator is null