Esempio n. 1
0
  @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));
  }
Esempio n. 2
0
 @Test
 public void testValues() {
   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);
   ByteArrayList values = new ByteArrayList(100);
   map.values(values);
   assertEquals(3, values.size());
   values.sort();
   assertEquals(22, values.get(0));
   assertEquals(23, values.get(1));
   assertEquals(25, values.get(2));
 }