コード例 #1
0
  boolean validate(MappeableBitmapContainer bc, MappeableArrayContainer ac) {
    // Checking the cardinalities of each container

    if (bc.getCardinality() != ac.getCardinality()) {
      System.out.println("cardinality differs");
      return false;
    }
    // Checking that the two containers contain the same values
    int counter = 0;

    int i = bc.nextSetBit(0);
    while (i >= 0) {
      ++counter;
      if (!ac.contains((short) i)) {
        System.out.println("content differs");
        System.out.println(bc);
        System.out.println(ac);
        return false;
      }
      i = bc.nextSetBit(i + 1);
    }

    // checking the cardinality of the BitmapContainer
    return counter == bc.getCardinality();
  }
コード例 #2
0
 @Test
 public void BitmapContainerCardinalityTest() {
   final MappeableBitmapContainer ac = new MappeableBitmapContainer();
   for (short k = 0; k < 100; ++k) {
     ac.add(k);
     Assert.assertEquals(ac.getCardinality(), k + 1);
   }
   for (short k = 0; k < 100; ++k) {
     ac.add(k);
     Assert.assertEquals(ac.getCardinality(), 100);
   }
 }