APIdia Launch Partner
Top Description Fields Constructors Methods
java.nio

pack-priv Class CharBufferSpliterator

extends Object
implements OfInt
Class Inheritance
All Implemented Interfaces
java.util.Spliterator.OfInt, java.util.Spliterator.OfPrimitive, java.util.Spliterator
Imports
java.util.Comparator, .Spliterator, java.util.function.IntConsumer

A Spliterator.OfInt for sources that traverse and split elements maintained in a CharBuffer.

Implementation Note

The implementation is based on the code for the Array-based spliterators.

Field Summary

Modifier and TypeField and Description
private final CharBuffer
private int
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
CharBufferSpliterator(CharBuffer buffer, int origin, int limit)

Method Summary

Modifier and TypeMethod and Description
public int
characteristics()

Implements java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements.

public long
estimateSize()

Implements java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

public void
forEachRemaining(IntConsumer action)

Overrides default java.util.Spliterator.OfInt.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.

public boolean
tryAdvance(IntConsumer action)

Implements java.util.Spliterator.OfInt.tryAdvance.

If a remaining element exists, performs the given action on it, returning true; else returns false.

public Spliterator.OfInt
trySplit()

Implements java.util.Spliterator.OfInt.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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final CharBuffer buffer
indexback to summary
private int index
limitback to summary
private final int limit

Constructor Detail

CharBufferSpliteratorback to summary
pack-priv CharBufferSpliterator(CharBuffer buffer)
CharBufferSpliteratorback to summary
pack-priv CharBufferSpliterator(CharBuffer buffer, int origin, int limit)

Method Detail

characteristicsback to summary
public int characteristics()

Implements java.util.Spliterator.characteristics.

Doc from java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements. The result is represented as ORed values from ORDERED, DISTINCT, SORTED, SIZED, NONNULL, IMMUTABLE, CONCURRENT, 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.

Annotations
@Override
estimateSizeback to summary
public long estimateSize()

Implements java.util.Spliterator.estimateSize.

Doc from java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

If this Spliterator is SIZED and has not yet been partially traversed or split, or this Spliterator is 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 trySplit.

Annotations
@Override
forEachRemainingback to summary
public void forEachRemaining(IntConsumer action)

Overrides default java.util.Spliterator.OfInt.forEachRemaining.

Doc from java.util.Spliterator.OfPrimitive.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 is 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.

Annotations
@Override
tryAdvanceback to summary
public boolean tryAdvance(IntConsumer action)

Implements java.util.Spliterator.OfInt.tryAdvance.

Doc from java.util.Spliterator.OfPrimitive.tryAdvance.

If a remaining element exists, performs the given action on it, returning true; else returns false. If this Spliterator is ORDERED the 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.

Annotations
@Override
trySplitback to summary
public Spliterator.OfInt trySplit()

Implements java.util.Spliterator.OfInt.trySplit.

Doc from 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.

If this Spliterator is 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.

Annotations
@Override