MCPcopy
hub / github.com/apache/groovy / sumTwoMaps

Method sumTwoMaps

benchmark/bench/knucleotide.java:51–60  ·  view source on GitHub ↗
(Map<String, knucleotide> map1, Map<String, knucleotide> map2)

Source from the content-addressed store, hash-verified

49
50 // Destructive!
51 static Map<String, knucleotide> sumTwoMaps(Map<String, knucleotide> map1, Map<String, knucleotide> map2) {
52 for (Map.Entry<String, knucleotide> entry : map2.entrySet()) {
53 knucleotide sum = (knucleotide)map1.get(entry.getKey());
54 if (sum != null)
55 sum.count += entry.getValue().count;
56 else
57 map1.put(entry.getKey(), entry.getValue());
58 }
59 return map1;
60 }
61
62 static String writeFrequencies(Map<String, knucleotide> frequencies) {
63 ArrayList<knucleotide> list = new ArrayList<knucleotide>(frequencies.size());

Callers 1

mainMethod · 0.95

Calls 5

getMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
putMethod · 0.65
entrySetMethod · 0.45

Tested by

no test coverage detected