Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Constants](https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#inhconstants) \| [Protected Ctors](https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#proctors) \| [Methods](https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#inhmethods)

# Spliterators.AbstractSpliterator


`
public
static

abstract
class
Spliterators.AbstractSpliterator
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/util/Spliterator<T>


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.util.Spliterators.AbstractSpliterator\<T\> |

<br />

*** ** * ** ***

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

An extending class need only
implement `https://developer.android.com/reference/java/util/Spliterator#tryAdvance(java.util.function.Consumer<?%20super%20T>)`.
The extending class should override
`https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)`
if it can provide a more performant implementation.
**See also:**

- `https://developer.android.com/reference/java/util/Spliterators#spliterator(java.util.Iterator<?%20extends%20T>,%20long,%20int)`

## Summary

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/java/util/Spliterator` |---|---| | `int` | `https://developer.android.com/reference/java/util/Spliterator#CONCURRENT` Characteristic value signifying that the element source may be safely concurrently modified (allowing additions, replacements, and/or removals) by multiple threads without external synchronization. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#DISTINCT` Characteristic value signifying that, for each pair of encountered elements `x, y`, `!x.equals(y)`. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#IMMUTABLE` Characteristic 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. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#NONNULL` Characteristic value signifying that the source guarantees that encountered elements will not be `null`. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#ORDERED` Characteristic value signifying that an encounter order is defined for elements. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#SIZED` Characteristic value signifying that the value returned from `estimateSize()` 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. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#SORTED` Characteristic value signifying that encounter order follows a defined sort order. | | `int` | `https://developer.android.com/reference/java/util/Spliterator#SUBSIZED` Characteristic value signifying that all Spliterators resulting from `trySplit()` will be both `https://developer.android.com/reference/java/util/Spliterator#SIZED` and `https://developer.android.com/reference/java/util/Spliterator#SUBSIZED`. | |

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#AbstractSpliterator(long,%20int)(long est, int additionalCharacteristics) ` Creates a spliterator reporting the given estimated size and additionalCharacteristics. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#characteristics()() ` Returns a set of characteristics of this Spliterator and its elements. |
| ` long` | ` https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#estimateSize()() ` Returns an estimate of the number of elements that would be encountered by a `https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)` traversal, or returns `https://developer.android.com/reference/java/lang/Long#MAX_VALUE` if infinite, unknown, or too expensive to compute. |
| ` https://developer.android.com/reference/java/util/Spliterator<T>` | ` https://developer.android.com/reference/java/util/Spliterators.AbstractSpliterator#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. This implementation permits limited parallelism. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/util/Spliterator ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/java/util/Spliterator#characteristics()() ` Returns a set of characteristics of this Spliterator and its elements. | | ` abstract long` | ` https://developer.android.com/reference/java/util/Spliterator#estimateSize()() ` Returns an estimate of the number of elements that would be encountered by a `https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)` traversal, or returns `https://developer.android.com/reference/java/lang/Long#MAX_VALUE` if infinite, unknown, or too expensive to compute. | | ` default void` | ` https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)(https://developer.android.com/reference/java/util/function/Consumer<? super T> 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 https://developer.android.com/reference/java/util/Comparator<? super T>` | ` https://developer.android.com/reference/java/util/Spliterator#getComparator()() ` If this Spliterator's source is `https://developer.android.com/reference/java/util/Spliterator#SORTED` by a `https://developer.android.com/reference/java/util/Comparator`, returns that `Comparator`. | | ` default long` | ` https://developer.android.com/reference/java/util/Spliterator#getExactSizeIfKnown()() ` Convenience method that returns `https://developer.android.com/reference/java/util/Spliterator#estimateSize()` if this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#SIZED`, else `-1`. | | ` default boolean` | ` https://developer.android.com/reference/java/util/Spliterator#hasCharacteristics(int)(int characteristics) ` Returns `true` if this Spliterator's `https://developer.android.com/reference/java/util/Spliterator#characteristics()` contain all of the given characteristics. | | ` abstract boolean` | ` https://developer.android.com/reference/java/util/Spliterator#tryAdvance(java.util.function.Consumer<?%20super%20T>)(https://developer.android.com/reference/java/util/function/Consumer<? super T> action) ` If a remaining element exists: performs the given action on it, returning `true`; else returns `false`. | | ` abstract https://developer.android.com/reference/java/util/Spliterator<T>` | ` https://developer.android.com/reference/java/util/Spliterator#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. | ||

## Protected constructors

### AbstractSpliterator

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected AbstractSpliterator (long est, 
                int additionalCharacteristics)
```

Creates a spliterator reporting the given estimated size and
additionalCharacteristics.

<br />

| Parameters ||
|---|---|
| `est` | `long`: the estimated size of this spliterator if known, otherwise `Long.MAX_VALUE`. <br /> |
| `additionalCharacteristics` | `int`: properties of this spliterator's source or elements. If `SIZED` is reported then this spliterator will additionally report `SUBSIZED`. <br /> |

## Public methods

### characteristics

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int characteristics ()
```

Returns a set of characteristics of this Spliterator and its
elements. The result is represented as ORed values from `https://developer.android.com/reference/java/util/Spliterator#ORDERED`, `https://developer.android.com/reference/java/util/Spliterator#DISTINCT`, `https://developer.android.com/reference/java/util/Spliterator#SORTED`, `https://developer.android.com/reference/java/util/Spliterator#SIZED`,
`https://developer.android.com/reference/java/util/Spliterator#NONNULL`, `https://developer.android.com/reference/java/util/Spliterator#IMMUTABLE`, `https://developer.android.com/reference/java/util/Spliterator#CONCURRENT`,
`https://developer.android.com/reference/java/util/Spliterator#SUBSIZED`. Repeated calls to `characteristics()` on
a given spliterator, prior to or in-between calls to `trySplit`,
should always return the same result.

If a Spliterator reports an inconsistent set of
characteristics (either those returned from a single invocation
or across multiple invocations), no guarantees can be made
about any computation using this Spliterator.

<br />

##### Implementation Requirements:

- This implementation returns the characteristics as reported when created.

| Returns ||
|---|---|
| `int` | a representation of characteristics <br /> |

### estimateSize

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long estimateSize ()
```

Returns an estimate of the number of elements that would be
encountered by a `https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)` traversal, or returns `https://developer.android.com/reference/java/lang/Long#MAX_VALUE` if infinite, unknown, or too expensive to compute.

If this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#SIZED` and has not yet been partially
traversed or split, or this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#SUBSIZED` and has
not yet been partially traversed, this estimate must be an accurate
count of elements that would be encountered by a complete traversal.
Otherwise, this estimate may be arbitrarily inaccurate, but must decrease
as specified across invocations of `https://developer.android.com/reference/java/util/Spliterator#trySplit()`.

<br />

##### Implementation Requirements:

- This implementation returns the estimated size as reported when created and, if the estimate size is known, decreases in size when split.

| Returns ||
|---|---|
| `long` | the estimated size, or `Long.MAX_VALUE` if infinite, unknown, or too expensive to compute. <br /> |

### trySplit

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Spliterator<T> 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.

If this Spliterator is `https://developer.android.com/reference/java/util/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 return `null`.
Upon non-null return:

- the value reported for `estimateSize()` before splitting, must, after splitting, be greater than or equal to `estimateSize()` for this and the returned Spliterator; and
- if this Spliterator is `SUBSIZED`, then `estimateSize()` for this spliterator before splitting must be equal to the sum of `estimateSize()` for this and the returned Spliterator after splitting.

This method may return `null` for any reason,
including emptiness, inability to split after traversal has
commenced, data structure constraints, and efficiency
considerations.

This implementation permits limited parallelism.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Spliterator<T>` | a `Spliterator` covering some portion of the elements, or `null` if this spliterator cannot be split <br /> |