Exemple #1
0
  @Test
  public void test_delete() {
    HTreeMap m =
        new HTreeMap(recman, true) {
          @Override
          protected int hash(Object key) {
            return 0;
          }
        };

    for (long i = 0; i < 20; i++) {
      m.put(i, i + 100);
    }

    for (long i = 0; i < 20; i++) {
      assertTrue(m.containsKey(i));
      assertEquals(i + 100, m.get(i));
    }

    for (long i = 0; i < 20; i++) {
      m.remove(i);
    }

    for (long i = 0; i < 20; i++) {
      assertTrue(!m.containsKey(i));
      assertEquals(null, m.get(i));
    }
  }
Exemple #2
0
  @Test
  public void test_simple_put() {

    HTreeMap m = new HTreeMap(recman, true);

    m.put(111L, 222L);
    m.put(333L, 444L);
    assertTrue(m.containsKey(111L));
    assertTrue(!m.containsKey(222L));
    assertTrue(m.containsKey(333L));
    assertTrue(!m.containsKey(444L));

    assertEquals(222L, m.get(111L));
    assertEquals(null, m.get(222L));
    assertEquals(444l, m.get(333L));
  }
Exemple #3
0
  @Test
  public void test_hash_collision() {
    HTreeMap m =
        new HTreeMap(recman, true) {
          @Override
          protected int hash(Object key) {
            return 0;
          }
        };

    for (long i = 0; i < 20; i++) {
      m.put(i, i + 100);
    }

    for (long i = 0; i < 20; i++) {
      assertTrue(m.containsKey(i));
      assertEquals(i + 100, m.get(i));
    }

    m.put(11L, 1111L);
    assertEquals(1111L, m.get(11L));
  }