IntIntMap { public int sum() { int result = 0; for (int v : _map.values()) { result += v; } return result; } IntIntMap();  IntIntMap(IntIntMap source);  IntIntMap(int initialCapacity); int size(); int sum(); int[] keySet(); boolean contains(int key); void put(int key, int value); void add(int key, int value); int getValue(int key); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testSum() { IntIntMap map = new IntIntMap(1000); final int numEntries = 2000; for (int i = 1; i <= numEntries; i++) { int value = i * 100; map.add(i, value); } int target = 100 * ((numEntries * numEntries) + numEntries) / 2; assertEquals(target, map.sum()); }