Examples of HMapIS


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

  public void testBasic1() {
    int size = 10000;
    Random r = new Random();
    short[] shorts = new short[size];

    MapIS map = new HMapIS();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, (short) (k * 2));
      shorts[i] = (short) (k * 2);
    }

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

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

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

  public void testUpdate() {
    int size = 10000;
    Random r = new Random();
    short[] shorts = new short[size];

    MapIS map = new HMapIS();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, (short) (k + 10));
      shorts[i] = (short) (k + 10);
    }

    assertEquals(size, map.size());

    for (int i = 0; i < size; i++) {
      map.put(i, (short) (shorts[i] + 10));
    }

    assertEquals(size, map.size());

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

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

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

    }
  }

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

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

    short value;

    assertEquals(2, m.size());

    value = m.get(1);
    assertEquals(5, value);

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

    value = m.get(2);
    assertEquals(22L, value);
  }
View Full Code Here

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

    assertEquals(22L, value);
  }

  @Test
  public void testPlus() throws IOException {
    HMapIS m1 = new HMapIS();

    m1.put(1, (short) 5);
    m1.put(2, (short) 22);

    HMapIS m2 = new HMapIS();

    m2.put(1, (short) 4);
    m2.put(3, (short) 5);

    m1.plus(m2);

    assertEquals(m1.size(), 3);
    assertTrue(m1.get(1) == 9);
View Full Code Here

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

    assertTrue(m1.get(3) == 5);
  }

  @Test
  public void testDot() throws IOException {
    HMapIS m1 = new HMapIS();

    m1.put(1, (short) 2);
    m1.put(2, (short) 1);
    m1.put(3, (short) 3);

    HMapIS m2 = new HMapIS();

    m2.put(1, (short) 1);
    m2.put(2, (short) 4);
    m2.put(4, (short) 5);

    int s = m1.dot(m2);

    assertEquals(6, s);
  }
View Full Code Here

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

    assertEquals(6, s);
  }

  @Test
  public void testSortedEntries1() {
    HMapIS m = new HMapIS();

    m.put(1, (short) 5);
    m.put(2, (short) 2);
    m.put(3, (short) 3);
    m.put(4, (short) 3);
    m.put(5, (short) 1);

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

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

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

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

  @Test
  public void testSortedEntries2() {
    HMapIS m = new HMapIS();

    m.put(1, (short) 5);
    m.put(2, (short) 2);
    m.put(3, (short) 3);
    m.put(4, (short) 3);
    m.put(5, (short) 1);

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

    assertEquals(2, e.length);

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

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

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

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

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

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

    assertEquals(2, e.length);

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

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

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

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

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

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

    assertTrue(e == null);
  }

  @Test
  public void testIncrement() {
    HMapIS m = new HMapIS();
    assertEquals(0, m.get(1));

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

    m.increment(1, (short) 1);
    m.increment(2, (short) 0);
    m.increment(3, (short) -1);

    assertEquals(2, m.get(1));
    assertEquals(0, m.get(2));
    assertEquals(-1, m.get(3));
  }
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.