@Test public void testKeys() { OpenDoubleObjectHashMap<TestClass> map = new OpenDoubleObjectHashMap<TestClass>(); map.put((double) 11, item); map.put((double) 12, item); DoubleArrayList keys = new DoubleArrayList(); map.keys(keys); keys.sort(); assertEquals(11, keys.get(0), (double) 0.000001); assertEquals(12, keys.get(1), (double) 0.000001); DoubleArrayList k2 = map.keys(); k2.sort(); assertEquals(keys, k2); }
@Test public void testPairsMatching() { DoubleArrayList keyList = new DoubleArrayList(); List<TestClass> valueList = new ArrayList<TestClass>(); OpenDoubleObjectHashMap<TestClass> map = new OpenDoubleObjectHashMap<TestClass>(); map.put((double) 11, anotherItem2); map.put((double) 12, anotherItem3); map.put((double) 13, anotherItem4); map.put((double) 14, anotherItem5); map.removeKey((double) 13); map.pairsMatching( new DoubleObjectProcedure<TestClass>() { @Override public boolean apply(double first, TestClass second) { return (first % 2) == 0; } }, keyList, valueList); keyList.sort(); Collections.sort(valueList); assertEquals(2, keyList.size()); assertEquals(2, valueList.size()); assertEquals(12, keyList.get(0), (double) 0.000001); assertEquals(14, keyList.get(1), (double) 0.000001); assertSame(anotherItem3, valueList.get(0)); assertSame(anotherItem5, valueList.get(1)); }
@Test public void testPairsMatching() { ShortArrayList keyList = new ShortArrayList(); DoubleArrayList valueList = new DoubleArrayList(); OpenShortDoubleHashMap map = new OpenShortDoubleHashMap(); map.put((short) 11, (double) 22); map.put((short) 12, (double) 23); map.put((short) 13, (double) 24); map.put((short) 14, (double) 25); map.removeKey((short) 13); map.pairsMatching( new ShortDoubleProcedure() { @Override public boolean apply(short first, double second) { return (first % 2) == 0; } }, keyList, valueList); keyList.sort(); valueList.sort(); assertEquals(2, keyList.size()); assertEquals(2, valueList.size()); assertEquals(12, keyList.get(0)); assertEquals(14, keyList.get(1)); assertEquals(23, valueList.get(0), (double) 0.000001); assertEquals(25, valueList.get(1), (double) 0.000001); }
@Test public void testValues() { OpenShortDoubleHashMap map = new OpenShortDoubleHashMap(); map.put((short) 11, (double) 22); map.put((short) 12, (double) 23); map.put((short) 13, (double) 24); map.put((short) 14, (double) 25); map.removeKey((short) 13); DoubleArrayList values = new DoubleArrayList(100); map.values(values); assertEquals(3, values.size()); values.sort(); assertEquals(22, values.get(0), (double) 0.000001); assertEquals(23, values.get(1), (double) 0.000001); assertEquals(25, values.get(2), (double) 0.000001); }