jdk/src/share/classes/java/util/PrimitiveIterator.java
changeset 18530 f28682666cf7
parent 17930 8e80bd9fda30
child 21339 20e8b81964d5
--- a/jdk/src/share/classes/java/util/PrimitiveIterator.java	Thu Jun 20 11:15:23 2013 +0200
+++ b/jdk/src/share/classes/java/util/PrimitiveIterator.java	Thu Jun 20 11:21:13 2013 +0200
@@ -55,16 +55,34 @@
  * is set to {@code true} then diagnostic warnings are reported if boxing of
  * primitive values occur when operating on primitive subtype specializations.
  *
- * @param <T> the boxed type of the primitive type
+ * @param <T> the type of elements returned by this PrimitiveIterator.  The
+ *        type must be a wrapper type for a primitive type, such as
+ *        {@code Integer} for the primitive {@code int} type.
+ * @param <T_CONS> the type of primitive consumer.  The type must be a
+ *        primitive specialization of {@link java.util.function.Consumer} for
+ *        {@code T}, such as {@link java.util.function.IntConsumer} for
+ *        {@code Integer}.
+ *
  * @since 1.8
  */
-public interface PrimitiveIterator<T> extends Iterator<T> {
+public interface PrimitiveIterator<T, T_CONS> extends Iterator<T> {
+
+    /**
+     * Performs the given action for each remaining element, in the order
+     * elements occur when iterating, until all elements have been processed
+     * or the action throws an exception.  Errors or runtime exceptions
+     * thrown by the action are relayed to the caller.
+     *
+     * @param action The action to be performed for each element
+     * @throws NullPointerException if the specified action is null
+     */
+    void forEachRemaining(T_CONS action);
 
     /**
      * An Iterator specialized for {@code int} values.
      * @since 1.8
      */
-    public static interface OfInt extends PrimitiveIterator<Integer> {
+    public static interface OfInt extends PrimitiveIterator<Integer, IntConsumer> {
 
         /**
          * Returns the next {@code int} element in the iteration.
@@ -138,7 +156,7 @@
      * An Iterator specialized for {@code long} values.
      * @since 1.8
      */
-    public static interface OfLong extends PrimitiveIterator<Long> {
+    public static interface OfLong extends PrimitiveIterator<Long, LongConsumer> {
 
         /**
          * Returns the next {@code long} element in the iteration.
@@ -211,7 +229,7 @@
      * An Iterator specialized for {@code double} values.
      * @since 1.8
      */
-    public static interface OfDouble extends PrimitiveIterator<Double> {
+    public static interface OfDouble extends PrimitiveIterator<Double, DoubleConsumer> {
 
         /**
          * Returns the next {@code double} element in the iteration.