@Override public Container add(int begin, int end) { BitmapContainer answer = clone(); Util.setBitmapRange(answer.bitmap, begin, end); answer.computeCardinality(); return answer; }
@Override public Container remove(int begin, int end) { BitmapContainer answer = clone(); Util.resetBitmapRange(answer.bitmap, begin, end); answer.computeCardinality(); if (answer.getCardinality() <= ArrayContainer.DEFAULT_MAX_SIZE) return answer.toArrayContainer(); return answer; }
@Override public Container andNot(RunContainer x) { // could be rewritten as return andNot(x.toBitmapOrArrayContainer()); BitmapContainer answer = this.clone(); for (int rlepos = 0; rlepos < x.nbrruns; ++rlepos) { int start = Util.toIntUnsigned(x.getValue(rlepos)); int end = start + Util.toIntUnsigned(x.getLength(rlepos)) + 1; Util.resetBitmapRange(answer.bitmap, start, end); } answer.computeCardinality(); if (answer.getCardinality() > ArrayContainer.DEFAULT_MAX_SIZE) return answer; else return answer.toArrayContainer(); }