jdk/src/share/classes/java/util/LinkedHashMap.java
changeset 18280 6c3c0ff49eb5
parent 18156 edb590d448c5
child 19435 9d7530ff42cb
--- a/jdk/src/share/classes/java/util/LinkedHashMap.java	Tue Jun 18 14:11:45 2013 -0700
+++ b/jdk/src/share/classes/java/util/LinkedHashMap.java	Tue Jun 18 16:03:10 2013 -0700
@@ -25,6 +25,8 @@
 
 package java.util;
 import java.io.*;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
 
 /**
  * <p>Hash table and linked list implementation of the <tt>Map</tt> interface,
@@ -296,6 +298,32 @@
         header.before = header.after = header;
     }
 
+    @Override
+    public void forEach(BiConsumer<? super K, ? super V> action) {
+        Objects.requireNonNull(action);
+        int expectedModCount = modCount;
+        for (Entry<K, V> entry = header.after; entry != header; entry = entry.after) {
+            action.accept(entry.key, entry.value);
+
+            if (expectedModCount != modCount) {
+                throw new ConcurrentModificationException();
+            }
+        }
+    }
+
+    @Override
+    public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
+        Objects.requireNonNull(function);
+        int expectedModCount = modCount;
+        for (Entry<K, V> entry = header.after; entry != header; entry = entry.after) {
+            entry.value = function.apply(entry.key, entry.value);
+
+            if (expectedModCount != modCount) {
+                throw new ConcurrentModificationException();
+            }
+        }
+    }
+
     /**
      * LinkedHashMap entry.
      */