Beispiel #1
0
 public void test2() {
   LongHashMap<String> v1 = new LongHashMap<String>();
   v1.put(1611, "1611");
   v1.put(15500, "15500");
   v1.put(9446, "9446");
   System.out.println(v1.get(9446));
   System.out.println(v1.toString());
   assertEquals(3, v1.size());
   assertEquals(v1.get(9446), "9446");
 }
Beispiel #2
0
  public void testAll() {
    LongHashMap<String> t = new LongHashMap<String>();
    t.put(1, "aa");
    t.put(2, "bb");
    t.put(2, "bb");
    t.put(4, "cc");
    t.put(9, "FF");
    assertEquals(4, t.size());
    t.remove(1);
    assertEquals(3, t.size());
    assertEquals(t.get(1), null);
    assertEquals(t.get(2), "bb");
    assertEquals(t.get(3), null);
    assertEquals(t.get(4), "cc");
    assertEquals(t.get(5), null);
    assertEquals(t.get(-1), null);
    assertEquals(t.get(9), "FF");

    Iterator<String> vals = t.valuesIterator();
    assertTrue(vals.hasNext());
    assertEquals(vals.next(), "FF");
    assertTrue(vals.hasNext());
    assertEquals(vals.next(), "cc");
    assertTrue(vals.hasNext());
    assertEquals(vals.next(), "bb");

    assertFalse(vals.hasNext());

    t.clear();
    assertEquals(0, t.size());
    t.put(2, "bb");
    assertEquals(1, t.size());
    assertEquals(t.get(1), null);
    assertEquals(t.get(2), "bb");
    assertEquals(t.get(3), null);
  }