public int orCardinality(BitmapCollection bitmaps) {
    ImmutableRoaringBitmap left = reduceInternal();
    ImmutableRoaringBitmap right = bitmaps.reduceInternal();
    if (!_inverted) {
      if (!bitmaps._inverted) {
        return ImmutableRoaringBitmap.orCardinality(left, right);
      }
      return _numDocs - right.getCardinality() - ImmutableRoaringBitmap.andCardinality(left, right);
    } else {
      if (!bitmaps._inverted) {
        return _numDocs - left.getCardinality()
            + ImmutableRoaringBitmap.andCardinality(right, left);
      }
      return _numDocs - ImmutableRoaringBitmap.andCardinality(left, right);
    }
  }
@Test(dataProvider = "orCardinalityTestCases")
  public void testOrCardinality(int numDocs, ImmutableRoaringBitmap left, boolean leftInverted,
      ImmutableRoaringBitmap right, boolean rightInverted, int expected) {
    assertEquals(new BitmapCollection(numDocs, leftInverted, left).orCardinality(
        new BitmapCollection(numDocs, rightInverted, right)), expected);
    assertEquals(new BitmapCollection(numDocs, leftInverted, split(left)).orCardinality(
        new BitmapCollection(numDocs, rightInverted, right)), expected);
    assertEquals(new BitmapCollection(numDocs, leftInverted, left).orCardinality(
        new BitmapCollection(numDocs, rightInverted, split(right))), expected);
    assertEquals(new BitmapCollection(numDocs, leftInverted, split(left)).orCardinality(
        new BitmapCollection(numDocs, rightInverted, split(right))), expected);
  }