@Test public void testKeys() { OpenIntByteHashMap map = new OpenIntByteHashMap(); map.put((int) 11, (byte) 22); map.put((int) 12, (byte) 22); IntArrayList keys = new IntArrayList(); map.keys(keys); keys.sort(); assertEquals(11, keys.get(0)); assertEquals(12, keys.get(1)); IntArrayList k2 = map.keys(); k2.sort(); assertEquals(keys, k2); }
@Test public void testPairsMatching() { IntArrayList keyList = new IntArrayList(); ByteArrayList valueList = new ByteArrayList(); OpenIntByteHashMap map = new OpenIntByteHashMap(); map.put((int) 11, (byte) 22); map.put((int) 12, (byte) 23); map.put((int) 13, (byte) 24); map.put((int) 14, (byte) 25); map.removeKey((int) 13); map.pairsMatching( new IntByteProcedure() { @Override public boolean apply(int first, byte 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)); assertEquals(25, valueList.get(1)); }