Performs the given action for each entry(key-value mapping) in this fact until all entries have been processed or the action throws an exception. @param action the action to be performed for each entry.
(BiConsumer<K, V> action)
| 128 | * @param action the action to be performed for each entry. |
| 129 | */ |
| 130 | public void forEach(BiConsumer<K, V> action) { |
| 131 | Objects.requireNonNull(action); |
| 132 | entries().forEach(entry -> { |
| 133 | K k; |
| 134 | V v; |
| 135 | try { |
| 136 | k = entry.getKey(); |
| 137 | v = entry.getValue(); |
| 138 | } catch (IllegalStateException ise) { |
| 139 | // this usually means the entry is no longer in the map. |
| 140 | throw new ConcurrentModificationException(ise); |
| 141 | } |
| 142 | action.accept(k, v); |
| 143 | }); |
| 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public boolean equals(Object o) { |