Most visited

Recently visited

Added in API level 24

Spliterator.OfPrimitive

public static interface Spliterator.OfPrimitive
implements Spliterator<T>

java.util.Spliterator.OfPrimitive<T, T_CONS, T_SPLITR extends java.util.Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>>
Known Indirect Subclasses


专为原始值设计的Spliterator。

也可以看看:

Summary

Inherited constants

From interface java.util.Spliterator

Public methods

default void forEachRemaining(T_CONS action)

对当前线程中的每个剩余元素执行给定操作,直到处理完所有元素或操作抛出异常。

abstract boolean tryAdvance(T_CONS action)

如果剩余的元素存在,则对其执行给定的操作,返回true ; 否则返回false

abstract T_SPLITR trySplit()

如果这个分割器可以被分割,返回一个Spliterator覆盖元素,当从这个方法返回时,不会被这个分割器覆盖。

Inherited methods

From interface java.util.Spliterator

Public methods

forEachRemaining

Added in API level 24
void forEachRemaining (T_CONS action)

对当前线程中的每个剩余元素执行给定操作,直到处理完所有元素或操作抛出异常。 如果此Spliterator是ORDERED ,则按照相遇顺序执行操作。 该操作引发的异常会中继给调用者。

实现要求:
  • The default implementation repeatedly invokes tryAdvance(T_CONS) until it returns false. It should be overridden whenever possible.
Parameters
action T_CONS: The action
Throws
NullPointerException if the specified action is null

tryAdvance

Added in API level 24
boolean tryAdvance (T_CONS action)

如果剩余的元素存在,则对其执行给定的操作,返回true ; 否则返回false 如果这个Spliterator是ORDERED ,那么这个动作是在遇到次序中的下一个元素上执行的。 该操作引发的异常会中继给调用者。

Parameters
action T_CONS: The action
Returns
boolean false if no remaining elements existed upon entry to this method, else true.
Throws
NullPointerException if the specified action is null

trySplit

Added in API level 24
T_SPLITR trySplit ()

如果这个分割器可以被分割,返回一个Spliterator覆盖元素,当从这个方法返回时,不会被这个分割器覆盖。

如果此Spliterator为 ORDERED ,则返回的Spliterator必须覆盖元素的严格前缀。

除非此Spliterator覆盖无限数量的元素,否则重复调用trySplit()最终必须返回null 非空返回时:

  • 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.

此方法可能因任何原因返回 null ,包括空行,遍历开始后无法拆分,数据结构约束和效率考虑。

Returns
T_SPLITR a Spliterator covering some portion of the elements, or null if this spliterator cannot be split

Hooray!