-
- 参数类型
-
T- 此PrimitiveIterator返回的元素的类型。 该类型必须是基本类型的包装器类型,例如Integer用于原语int类型。 -
T_CONS- 原始消费者的类型。 该类型必须是T的T的原始专业化,例如IntConsumer(对于Integer。
- All Superinterfaces:
-
Iterator<T>
- All Known Subinterfaces:
-
PrimitiveIterator.OfDouble,PrimitiveIterator.OfInt,PrimitiveIterator.OfLong
public interface PrimitiveIterator<T,T_CONS> extends Iterator<T>
Iterator基本专长的基本类型。 提供了专门的亚型int,long,并double值。专门的子类型默认实现为
Iterator.next()和Iterator.forEachRemaining(java.util.function.Consumer)框原始值到其对应的包装器类的实例。 这种拳击可以抵消在使用原始专长时获得的任何优势。 为了避免拳击,应该使用相应的基于图元的方法。 例如,PrimitiveIterator.OfInt.nextInt()和PrimitiveIterator.OfInt.forEachRemaining(java.util.function.IntConsumer)应优先于PrimitiveIterator.OfInt.next()和PrimitiveIterator.OfInt.forEachRemaining(java.util.function.Consumer)使用 。使用基于拳击的方法
next()和forEachRemaining()对原始值的迭代不会影响遇到转换为框值的值的顺序。- Implementation Note:
-
如果布尔系统属性
org.openjdk.java.util.stream.tripwire设置为true则在对原始子类型专用化进行操作时,如果发生基本值的true则会报告诊断警告。 - 从以下版本开始:
- 1.8
-
-
Nested Class Summary
Nested Classes Modifier and Type 接口 描述 static interfacePrimitiveIterator.OfDouble一个专门针对double值的迭代器。static interfacePrimitiveIterator.OfInt一个专门针对int值的迭代器。static interfacePrimitiveIterator.OfLong一个专门针对long值的迭代器。
-
方法摘要
所有方法 接口方法 抽象方法 Modifier and Type 方法 描述 voidforEachRemaining(T_CONS action)对每个剩余的元素执行给定的动作,按照迭代时发生的顺序,直到所有元素都被处理或动作引发异常。-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
-
-
-
方法详细信息
-
forEachRemaining
void forEachRemaining(T_CONS action)
对每个剩余的元素执行给定的动作,按照迭代时发生的顺序,直到所有元素都被处理或动作引发异常。 该操作抛出的错误或运行时异常被转发给调用者。- 参数
-
action- 要为每个元素执行的操作 - 异常
-
NullPointerException- 如果指定的操作为空
-
-