class SplitMap {

  public long getCardinality() {
    return index.reduceLong(0L, Container::getCardinality, (x, y) -> x + y);
  }

}

class SplitMapTest {

  @Test
  public void testCardinality() {

    SplitMapPageWriter writer = new SplitMapPageWriter();
    writer.add(1);
    writer.add(1 << 14);
    writer.add(1 << 16 | 1);
    writer.add(1 << 17);
    assertEquals(writer.toSplitMap().getCardinality(), 4);
  }

}