Skip to content

Commit 7790a18

Browse files
committed
Iterate over entrySet of j.u.Map instead of keySet + get
1 parent e76812f commit 7790a18

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

core/src/main/java/fj/data/HashMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public HashMap(final Equal<K> e, final Hash<K> h) {
6363

6464
public HashMap(java.util.Map<K, V> map, final Equal<K> e, final Hash<K> h) {
6565
this(e, h);
66-
for (K key : map.keySet()) {
67-
set(key, map.get(key));
66+
for (Map.Entry<K, V> entry : map.entrySet()) {
67+
set(entry.getKey(), entry.getValue());
6868
}
6969
}
7070

quickcheck/src/main/java/fj/test/Arbitrary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,8 @@ public static <A> Arbitrary<PriorityQueue<A>> arbPriorityQueue(final Arbitrary<A
928928
arbitrary(arbHashtable(arbString, arbString).gen.map(ht -> {
929929
final Properties p = new Properties();
930930

931-
for (final String k : ht.keySet()) {
932-
p.setProperty(k, ht.get(k));
931+
for (final Map.Entry<String, String> entry : ht.entrySet()) {
932+
p.setProperty(entry.getKey(), entry.getValue());
933933
}
934934

935935
return p;

quickcheck/src/main/java/fj/test/Coarbitrary.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.LinkedHashMap;
3434
import java.util.LinkedHashSet;
3535
import java.util.LinkedList;
36+
import java.util.Map;
3637
import java.util.PriorityQueue;
3738
import java.util.Properties;
3839
import java.util.Stack;
@@ -647,8 +648,8 @@ public static <K, V> Coarbitrary<Hashtable<K, V>> coarbHashtable(final Coarbitra
647648
public <B> Gen<B> coarbitrary(final Hashtable<K, V> h, final Gen<B> g) {
648649
List<P2<K, V>> x = nil();
649650

650-
for (final K k : h.keySet()) {
651-
x = x.snoc(p(k, h.get(k)));
651+
for (final Map.Entry<K, V> entry : h.entrySet()) {
652+
x = x.snoc(p(entry.getKey(), entry.getValue()));
652653
}
653654

654655
return coarbList(coarbP2(ck, cv)).coarbitrary(x, g);

quickcheck/src/main/java/fj/test/Shrink.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import java.util.LinkedHashMap;
5757
import java.util.LinkedHashSet;
5858
import java.util.LinkedList;
59+
import java.util.Map;
5960
import java.util.PriorityQueue;
6061
import java.util.Properties;
6162
import java.util.Stack;
@@ -411,8 +412,8 @@ public static <K, V> Shrink<Hashtable<K, V>> shrinkHashtable(final Shrink<K> sk,
411412
}, h -> {
412413
List<P2<K, V>> x = List.nil();
413414

414-
for (final K k : h.keySet()) {
415-
x = x.snoc(p(k, h.get(k)));
415+
for (final Map.Entry<K, V> entry : h.entrySet()) {
416+
x = x.snoc(p(entry.getKey(), entry.getValue()));
416417
}
417418

418419
return x;
@@ -478,8 +479,8 @@ public static <A> Shrink<PriorityQueue<A>> shrinkPriorityQueue(final Shrink<A> s
478479
.map(h -> {
479480
final Properties p = new Properties();
480481

481-
for (final String k : h.keySet()) {
482-
p.setProperty(k, h.get(k));
482+
for (final Map.Entry<String, String> entry : h.entrySet()) {
483+
p.setProperty(entry.getKey(), entry.getValue());
483484
}
484485

485486
return p;

0 commit comments

Comments
 (0)