boolean validate(BitmapContainer bc, ArrayContainer 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 if (counter != bc.getCardinality()) return false; return true; }