Examples of HMapII


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

  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

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

  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

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

    }
  }

  @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

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

    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

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

    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

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

  }

  @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

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

    assertEquals(doc.getNumberOfLanguages(), 0);
    assertEquals(doc.getNumberOfTypes(0), 0);
    assertEquals(doc.getNumberOfWords(0), 0);

    HMapII[] hmap = new HMapII[3];
    hmap[1] = new HMapII();
    hmap[1].put(1, 22);
    hmap[1].put(2, 5);
    hmap[1].put(3, 10);

    doc.setDocument(hmap);
View Full Code Here

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

  }

  @Test
  public void testSerialize1() throws IOException {
    HMapII[] hmap1 = new HMapII[3];
    hmap1[1] = new HMapII();
    hmap1[1].put(1, 22);
    hmap1[1].put(2, 5);
    hmap1[1].put(3, 10);

    double[] array1 = new double[2];
View Full Code Here

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

  }

  @Test
  public void testSerialize2() throws IOException {
    HMapII[] hmap1 = new HMapII[3];
    hmap1[1] = new HMapII();
    hmap1[1].put(1, 22);
    hmap1[1].put(2, 5);
    hmap1[1].put(3, 10);
    double[] array1 = null;
View Full Code Here

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

    assertEquals(doc1.getNumberOfTokens(), 0);
  }

  @Test
  public void testConstructor2() {
    HMapII hmap1 = new HMapII();
    hmap1.put(1, 22);
    hmap1.put(2, 5);
    hmap1.put(3, 10);

    Document doc1 = new Document(hmap1);
    assertTrue(doc1.getGamma() == null);
    assertEquals(doc1.getNumberOfTopics(), 0);

    assertTrue(doc1.getContent() != null);
    assertEquals(doc1.getNumberOfTokens(), 37);
    assertEquals(doc1.getNumberOfTypes(), hmap1.size());

    Iterator<Integer> itr = doc1.getContent().keySet().iterator();
    while (itr.hasNext()) {
      int key = itr.next();
      assertEquals(doc1.getContent().get(key), hmap1.get(key));
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.