Package edu.umd.cloud9.util.map

Examples of edu.umd.cloud9.util.map.HMapII


    assertEquals(3, e[1].getValue());
  }

  @Test
  public void testSortedEntries3() {
    HMapII m = new HMapII();

    m.put(1, 5);
    m.put(2, 2);

    Entry[] e = m.getEntriesSortedByValue(5);

    assertEquals(2, e.length);

    assertEquals(1, e[0].getKey());
    assertEquals(5, e[0].getValue());
View Full Code Here


    assertEquals(2, e[1].getValue());
  }

  @Test
  public void testSortedEntries4() {
    HMapII m = new HMapII();

    Entry[] e = m.getEntriesSortedByValue();
    assertTrue(e == null);
  }
View Full Code Here

    assertTrue(e == null);
  }

  @Test
  public void testPut() {
    HMapII m = new HMapII();
    // When we put a value, we should get back the old value.

    assertEquals(MapII.DEFAULT_VALUE, m.put(1, 5));
    assertEquals(5, m.put(1, 6));
    assertEquals(6, m.put(1, 2));
    assertEquals(2, m.get(1));
  }
View Full Code Here

    assertEquals(2, m.get(1));
  }

  @Test
  public void testIncrement() {
    HMapII m = new HMapII();
    // When we put a value, we should get back the old value.

    assertEquals(0, m.get(1));
    m.increment(1);

    assertEquals(1, m.get(1));
    m.increment(1, 5);
    m.increment(2, 0);
    m.increment(3, 2);

    assertEquals(6, m.get(1));
    assertEquals(0, m.get(2));
    assertEquals(2, m.get(3));
  }
View Full Code Here

  public void testBasic1() {
    int size = 100000;
    Random r = new Random();
    int[] ints = new int[size];

    MapII map = new HMapII();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, k);
      ints[i] = k;
    }

    for (int i = 0; i < size; i++) {
      int v = map.get(i);

      assertEquals(ints[i], v);
      assertTrue(map.containsKey(i));
    }

  }
View Full Code Here

  public void testUpdate() {
    int size = 100000;
    Random r = new Random();
    int[] ints = new int[size];

    MapII map = new HMapII();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, k);
      ints[i] = k;
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      map.put(i, ints[i] + 1);
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      int v = map.get(i);

      assertEquals(ints[i] + 1, v);
      assertTrue(map.containsKey(i));
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testBasic() throws IOException {
    HMapII m = new HMapII();

    m.put(1, 5);
    m.put(2, 22);

    float value;

    assertEquals(m.size(), 2);

    value = m.get(1);
    assertTrue(value == 5);

    value = m.remove(1);
    assertEquals(m.size(), 1);

    value = m.get(2);
    assertTrue(value == 22);
  }
View Full Code Here

    long startTime;
    long duration;
    Random r = new Random();

    System.out.println("Benchmarking HMapKI<String>...");
    MapII map = new HMapII();
    startTime = System.currentTimeMillis();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(1000);
      boolean increment = r.nextBoolean();
      if (increment) {
View Full Code Here

    int[] ints = new int[size];

    long usedMemory1 = MemoryUsageUtils.getUsedMemory();

    System.out.println("Benchmarking HMapII...");
    MapII map = new HMapII();

    startTime = System.currentTimeMillis();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, k);
      ints[i] = k;
    }
    duration = System.currentTimeMillis() - startTime;
    System.out.println(" Inserting " + size + " random entries: " + duration + " ms");

    startTime = System.currentTimeMillis();
    for (int i = 0; i < size; i++) {
      int v = map.get(i);

      if (v != ints[i])
        throw new RuntimeException("Values don't match!");
    }
    duration = System.currentTimeMillis() - startTime;
View Full Code Here

  }

  @Test
  public void testConstructor2() {
    HMapII[] hmaps = new HMapII[2];
    hmaps[0] = new HMapII();
    hmaps[0].put(6, 22);
    hmaps[0].put(12, 5);
    hmaps[0].put(23, 10);

    hmaps[1] = new HMapII();
    hmaps[1].put(1, 4);
    hmaps[1].put(2, 7);
    hmaps[1].put(3, 6);
    hmaps[1].put(4, 2);
View Full Code Here

TOP

Related Classes of edu.umd.cloud9.util.map.HMapII

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.