MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / create

Method create

onjava/FillMap.java:27–37  ·  view source on GitHub ↗
(Supplier<K> keyGen,
           Supplier<V> valueGen,
           Supplier<M> mapSupplier, int size)

Source from the content-addressed store, hash-verified

25 .toMap(Pair::key, Pair::value));
26 }
27 public static <K, V, M extends Map<K,V>>
28 M create(Supplier<K> keyGen,
29 Supplier<V> valueGen,
30 Supplier<M> mapSupplier, int size) {
31 return Stream.generate( () ->
32 Pair.make(keyGen.get(), valueGen.get()))
33 .limit(size)
34 .collect(Collectors
35 .toMap(Pair::key, Pair::value,
36 (k, v) -> k, mapSupplier));
37 }
38}

Callers 1

mainMethod · 0.95

Calls 2

makeMethod · 0.95
getMethod · 0.65

Tested by 1

mainMethod · 0.76