T - 此PrimitiveIterator返回的元素的类型。
该类型必须是对一个原始类型的包装类型,如Integer为原始int类型。
T_CONS - 原始消费者的类型。
该类型必须是T的Consumer的原始 T ,例如Integer的Integer 。
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)使用 。
org.openjdk.java.util.stream.tripwire设置为
true则在对原始子类型专门化进行操作时,如果出现原始值的封锁,则会报告诊断警告。
| Modifier and Type | Interface and Description |
|---|---|
static interface |
PrimitiveIterator.OfDouble
一个专门为
double值的迭代器。
|
static interface |
PrimitiveIterator.OfInt
一个专门为
int值的迭代器。
|
static interface |
PrimitiveIterator.OfLong
一个专门为
long值的迭代器。
|
| Modifier and Type | Method and Description |
|---|---|
void |
forEachRemaining(T_CONS action)
对每个剩余的元素执行给定的动作,按照迭代时发生的顺序,直到所有元素都被处理或动作引发异常。
|
forEachRemaining, hasNext, next, removevoid forEachRemaining(T_CONS action)
action - 要为每个元素执行的操作
NullPointerException - 如果指定的动作为空
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.