Exemplo n.º 1
0
 protected void setUp() throws Exception {
   // Cluster a bunch in the center
   int min = RANGE / 3;
   for (int i = 0; i < NUM_SAMPLES; i++) {
     int val = rand.nextInt(min) + min;
     h.put(val);
     fast_h.fastPut(val);
   }
   for (int i = 0; i < NUM_SAMPLES; i++) {
     int val = rand.nextInt(RANGE);
     h.put(val);
     fast_h.fastPut(val);
   }
 }
Exemplo n.º 2
0
  /** testSerialization */
  public void testSerialization() throws Exception {
    String json = fast_h.toJSONString();
    assertFalse(json.isEmpty());

    FastIntHistogram clone = new FastIntHistogram();
    JSONObject jsonObj = new JSONObject(json);
    clone.fromJSON(jsonObj, null);

    assertEquals(fast_h.fastSize(), clone.fastSize());
    for (int i = 0, cnt = fast_h.fastSize(); i < cnt; i++) {
      assertEquals(fast_h.fastGet(i), clone.fastGet(i));
    } // FOR
  }
Exemplo n.º 3
0
 /** testValues */
 public void testValues() throws Exception {
   Collection<Integer> vals0 = h.values();
   Collection<Integer> vals1 = fast_h.values();
   assertEquals(vals0.size(), vals1.size());
   assertTrue(vals0.containsAll(vals1));
 }
Exemplo n.º 4
0
 public void testMaxCountValues() {
   Collection<Integer> vals0 = h.getMaxCountValues();
   Collection<Integer> vals1 = fast_h.getMaxCountValues();
   assertEquals(vals0.size(), vals1.size());
   assertTrue(vals0.containsAll(vals1));
 }
Exemplo n.º 5
0
 public void testMaxValue() {
   assertEquals(h.getMaxValue(), fast_h.getMaxValue());
 }
Exemplo n.º 6
0
 /** testMaxCount */
 public void testMaxCount() throws Exception {
   assertEquals(h.getMaxCount(), fast_h.getMaxCount());
 }
Exemplo n.º 7
0
 /** testValueCount */
 public void testValueCount() {
   assertEquals(h.getValueCount(), fast_h.getValueCount());
 }