Most visited

Recently visited

Added in API level 24

Spliterators.AbstractLongSpliterator

public static abstract class Spliterators.AbstractLongSpliterator
extends Object implements Spliterator.OfLong

java.lang.Object
   ↳ java.util.Spliterators.AbstractLongSpliterator


抽象 Spliterator.OfLong ,实现 trySplit以允许有限的并行性。

要实现分割器,扩展类只需要实现tryAdvance(java.util.function.LongConsumer) tryAdvance}。 如果扩展类可以提供更高性能的实现,则应该覆盖forEachRemaining(java.util.function.LongConsumer) forEach}。

也可以看看:

Summary

Inherited constants

From interface java.util.Spliterator

Protected constructors

Spliterators.AbstractLongSpliterator(long est, int additionalCharacteristics)

创建报告给定的估计大小和特征的分割器。

Public methods

int characteristics()

返回此Spliterator及其元素的一组特征。

long estimateSize()

返回 forEachRemaining(Consumer )遍历将遇到的元素数量的估计值,如果无限,未知或计算成本太高,则返回 MAX_VALUE

Spliterator.OfLong trySplit()

如果这个分割器可以被分割,返回一个Spliterator覆盖元素,当从这个方法返回时,不会被这个分割器覆盖。 这种实现允许有限的并行性。

Inherited methods

From class java.lang.Object
From interface java.util.Spliterator.OfLong
From interface java.util.Spliterator.OfPrimitive
From interface java.util.Spliterator

Protected constructors

Spliterators.AbstractLongSpliterator

Added in API level 24
Spliterators.AbstractLongSpliterator (long est, 
                int additionalCharacteristics)

创建报告给定的估计大小和特征的分割器。

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

Public methods

characteristics

Added in API level 24
int characteristics ()

返回此Spliterator及其元素的一组特征。 结果从表示为或运算值ORDEREDDISTINCTSORTEDSIZEDNONNULLIMMUTABLECONCURRENTSUBSIZED 重复调用characteristics()在给定的spliterator之前或在两者之间的调用, trySplit ,应始终返回相同的结果。

如果Spliterator报告一组不一致的特征(无论是从单个调用还是跨多个调用返回的特征),都不能保证使用此Spliterator的任何计算。

实现要求:
  • This implementation returns the characteristics as reported when created.
Returns
int a representation of characteristics

estimateSize

Added in API level 24
long estimateSize ()

返回 forEachRemaining(Consumer )遍历将遇到的元素数的估计值,如果计算值无限,未知或代价过高,则返回 MAX_VALUE

如果这个Spliterator是SIZED并且尚未部分遍历或拆分,或者这个Spliterator是SUBSIZED并且尚未部分遍历,则此估计必须是完整遍历将遇到的元素的精确计数。 否则,这个估计可能是任意不准确的,但必须按照调用trySplit()规定降低。

实现要求:
  • 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.

trySplit

Added in API level 24
Spliterator.OfLong 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
Spliterator.OfLong a Spliterator covering some portion of the elements, or null if this spliterator cannot be split

Hooray!