@Test public void not() { MappeableRunContainer rc = newRunContainer(1, 13); MappeableContainer result = rc.not(5, 8); assertEquals(9, result.getCardinality()); for (int i = 1; i < 5; i++) { assertTrue(rc.contains((char) i)); } for (int i = 8; i < 13; i++) { assertTrue(rc.contains((char) i)); } }
@Override public MappeableContainer not(int rangeStart, int rangeEnd) { if (rangeEnd <= rangeStart) { return this.clone(); } MappeableRunContainer ans = new MappeableRunContainer(nbrruns + 1); if (!ans.isArrayBacked()) { throw new RuntimeException("internal bug"); } char[] vl = ans.valueslength.array(); int k = 0; if (isArrayBacked()) { char[] myVl = valueslength.array(); for (; k < this.nbrruns && (getValue(myVl, k)) < rangeStart; ++k) { vl[2 * k] = myVl[2 * k]; vl[2 * k + 1] = myVl[2 * k + 1]; ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(myVl, k), getLength(myVl, k)); } } else { for (; k < this.nbrruns && (this.getValue(k)) < rangeStart; ++k) { vl[2 * k] = getValue(k); vl[2 * k + 1] = getLength(k); ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(k), getLength(k)); } } return ans.toEfficientContainer(); }
MappeableRunContainer extends MappeableContainer implements Cloneable { @Override public MappeableContainer not(int rangeStart, int rangeEnd) { if (rangeEnd <= rangeStart) { return this.clone(); } MappeableRunContainer ans = new MappeableRunContainer(nbrruns + 1); if (!ans.isArrayBacked()) { throw new RuntimeException("internal bug"); } char[] vl = ans.valueslength.array(); int k = 0; if (isArrayBacked()) { char[] myVl = valueslength.array(); for (; k < this.nbrruns && (getValue(myVl, k)) < rangeStart; ++k) { vl[2 * k] = myVl[2 * k]; vl[2 * k + 1] = myVl[2 * k + 1]; ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(myVl, k), getLength(myVl, k)); } } else { for (; k < this.nbrruns && (this.getValue(k)) < rangeStart; ++k) { vl[2 * k] = getValue(k); vl[2 * k + 1] = getLength(k); ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(k), getLength(k)); } } return ans.toEfficientContainer(); } }
MappeableRunContainer extends MappeableContainer implements Cloneable { @Override public MappeableContainer not(int rangeStart, int rangeEnd) { if (rangeEnd <= rangeStart) { return this.clone(); } MappeableRunContainer ans = new MappeableRunContainer(nbrruns + 1); if (!ans.isArrayBacked()) { throw new RuntimeException("internal bug"); } char[] vl = ans.valueslength.array(); int k = 0; if (isArrayBacked()) { char[] myVl = valueslength.array(); for (; k < this.nbrruns && (getValue(myVl, k)) < rangeStart; ++k) { vl[2 * k] = myVl[2 * k]; vl[2 * k + 1] = myVl[2 * k + 1]; ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(myVl, k), getLength(myVl, k)); } } else { for (; k < this.nbrruns && (this.getValue(k)) < rangeStart; ++k) { vl[2 * k] = getValue(k); vl[2 * k + 1] = getLength(k); ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(k), getLength(k)); } } return ans.toEfficientContainer(); } MappeableRunContainer();  MappeableRunContainer(final int capacity); private  MappeableRunContainer(int nbrruns, final CharBuffer valueslength); protected  MappeableRunContainer(MappeableArrayContainer arr, int nbrRuns);  MappeableRunContainer(final int firstOfRun, final int lastOfRun); protected  MappeableRunContainer(MappeableBitmapContainer bc, int nbrRuns);  MappeableRunContainer(RunContainer bc);  MappeableRunContainer(final CharBuffer array, final int numRuns); }
MappeableRunContainer extends MappeableContainer implements Cloneable { @Override public MappeableContainer not(int rangeStart, int rangeEnd) { if (rangeEnd <= rangeStart) { return this.clone(); } MappeableRunContainer ans = new MappeableRunContainer(nbrruns + 1); if (!ans.isArrayBacked()) { throw new RuntimeException("internal bug"); } char[] vl = ans.valueslength.array(); int k = 0; if (isArrayBacked()) { char[] myVl = valueslength.array(); for (; k < this.nbrruns && (getValue(myVl, k)) < rangeStart; ++k) { vl[2 * k] = myVl[2 * k]; vl[2 * k + 1] = myVl[2 * k + 1]; ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(myVl, k), getLength(myVl, k)); } } else { for (; k < this.nbrruns && (this.getValue(k)) < rangeStart; ++k) { vl[2 * k] = getValue(k); vl[2 * k + 1] = getLength(k); ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(k), getLength(k)); } } return ans.toEfficientContainer(); } MappeableRunContainer();  MappeableRunContainer(final int capacity); private  MappeableRunContainer(int nbrruns, final CharBuffer valueslength); protected  MappeableRunContainer(MappeableArrayContainer arr, int nbrRuns);  MappeableRunContainer(final int firstOfRun, final int lastOfRun); protected  MappeableRunContainer(MappeableBitmapContainer bc, int nbrRuns);  MappeableRunContainer(RunContainer bc);  MappeableRunContainer(final CharBuffer array, final int numRuns); @Override MappeableContainer add(int begin, int end); @Override // not thread-safe MappeableContainer add(char k); @Override boolean isEmpty(); @Override MappeableContainer and(MappeableArrayContainer x); @Override MappeableContainer and(MappeableBitmapContainer x); @Override MappeableContainer and(MappeableRunContainer x); @Override MappeableContainer andNot(MappeableArrayContainer x); @Override MappeableContainer andNot(MappeableBitmapContainer x); @Override MappeableContainer andNot(MappeableRunContainer x); @Override void clear(); @Override MappeableContainer clone(); @Override boolean contains(char x); static boolean contains(ByteBuffer buf, int position, char x, final int numRuns); @Override boolean equals(Object o); @Override void fillLeastSignificant16bits(int[] x, int i, int mask); @Override MappeableContainer flip(char x); @Override int getCardinality(); char getLength(int index); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); char getValue(int index); @Override int hashCode(); @Override // not thread-safe MappeableContainer iadd(int begin, int end); @Override MappeableContainer iand(MappeableArrayContainer x); @Override MappeableContainer iand(MappeableBitmapContainer x); @Override MappeableContainer iand(MappeableRunContainer x); @Override MappeableContainer iandNot(MappeableArrayContainer x); @Override MappeableContainer iandNot(MappeableBitmapContainer x); @Override MappeableContainer iandNot(MappeableRunContainer x); @Override MappeableContainer inot(int rangeStart, int rangeEnd); @Override boolean intersects(MappeableArrayContainer x); @Override boolean intersects(MappeableBitmapContainer x); @Override boolean intersects(MappeableRunContainer x); @Override MappeableContainer ior(MappeableArrayContainer x); @Override MappeableContainer ior(MappeableBitmapContainer x); @Override MappeableContainer ior(MappeableRunContainer x); @Override // not thread-safe MappeableContainer iremove(int begin, int end); @Override boolean isFull(); static MappeableRunContainer full(); @Override Iterator<Character> iterator(); @Override MappeableContainer ixor(MappeableArrayContainer x); @Override MappeableContainer ixor(MappeableBitmapContainer x); @Override MappeableContainer ixor(MappeableRunContainer x); @Override MappeableContainer limit(int maxcardinality); @Override MappeableContainer not(int rangeStart, int rangeEnd); @Override int numberOfRuns(); @Override MappeableContainer or(MappeableArrayContainer x); @Override MappeableContainer or(MappeableBitmapContainer x); @Override MappeableContainer or(MappeableRunContainer x); @Override int rank(char lowbits); @Override void readExternal(ObjectInput in); @Override MappeableContainer remove(int begin, int end); @Override // not thread-safe MappeableContainer remove(char x); @Override MappeableContainer repairAfterLazy(); @Override MappeableContainer runOptimize(); @Override char select(int j); @Override int serializedSizeInBytes(); @Override Container toContainer(); char[] toCharArray(); @Override String toString(); @Override void trim(); @Override void writeExternal(ObjectOutput out); @Override MappeableContainer xor(MappeableArrayContainer x); @Override MappeableContainer xor(MappeableBitmapContainer x); @Override MappeableContainer xor(MappeableRunContainer x); @Override void forEach(char msb, IntConsumer ic); @Override int andCardinality(MappeableArrayContainer x); @Override int andCardinality(MappeableBitmapContainer x); @Override int andCardinality(MappeableRunContainer x); @Override MappeableBitmapContainer toBitmapContainer(); @Override int first(); @Override int last(); @Override int nextValue(char fromValue); @Override int previousValue(char fromValue); @Override int nextAbsentValue(char fromValue); @Override int previousAbsentValue(char fromValue); @Override boolean intersects(int minimum, int supremum); @Override boolean contains(int minimum, int supremum); }
MappeableRunContainer extends MappeableContainer implements Cloneable { @Override public MappeableContainer not(int rangeStart, int rangeEnd) { if (rangeEnd <= rangeStart) { return this.clone(); } MappeableRunContainer ans = new MappeableRunContainer(nbrruns + 1); if (!ans.isArrayBacked()) { throw new RuntimeException("internal bug"); } char[] vl = ans.valueslength.array(); int k = 0; if (isArrayBacked()) { char[] myVl = valueslength.array(); for (; k < this.nbrruns && (getValue(myVl, k)) < rangeStart; ++k) { vl[2 * k] = myVl[2 * k]; vl[2 * k + 1] = myVl[2 * k + 1]; ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(myVl, k), getLength(myVl, k)); } } else { for (; k < this.nbrruns && (this.getValue(k)) < rangeStart; ++k) { vl[2 * k] = getValue(k); vl[2 * k + 1] = getLength(k); ans.nbrruns++; } ans.smartAppendExclusive(vl, (char) rangeStart, (char) (rangeEnd - rangeStart - 1)); for (; k < this.nbrruns; ++k) { ans.smartAppendExclusive(vl, getValue(k), getLength(k)); } } return ans.toEfficientContainer(); } MappeableRunContainer();  MappeableRunContainer(final int capacity); private  MappeableRunContainer(int nbrruns, final CharBuffer valueslength); protected  MappeableRunContainer(MappeableArrayContainer arr, int nbrRuns);  MappeableRunContainer(final int firstOfRun, final int lastOfRun); protected  MappeableRunContainer(MappeableBitmapContainer bc, int nbrRuns);  MappeableRunContainer(RunContainer bc);  MappeableRunContainer(final CharBuffer array, final int numRuns); @Override MappeableContainer add(int begin, int end); @Override // not thread-safe MappeableContainer add(char k); @Override boolean isEmpty(); @Override MappeableContainer and(MappeableArrayContainer x); @Override MappeableContainer and(MappeableBitmapContainer x); @Override MappeableContainer and(MappeableRunContainer x); @Override MappeableContainer andNot(MappeableArrayContainer x); @Override MappeableContainer andNot(MappeableBitmapContainer x); @Override MappeableContainer andNot(MappeableRunContainer x); @Override void clear(); @Override MappeableContainer clone(); @Override boolean contains(char x); static boolean contains(ByteBuffer buf, int position, char x, final int numRuns); @Override boolean equals(Object o); @Override void fillLeastSignificant16bits(int[] x, int i, int mask); @Override MappeableContainer flip(char x); @Override int getCardinality(); char getLength(int index); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); char getValue(int index); @Override int hashCode(); @Override // not thread-safe MappeableContainer iadd(int begin, int end); @Override MappeableContainer iand(MappeableArrayContainer x); @Override MappeableContainer iand(MappeableBitmapContainer x); @Override MappeableContainer iand(MappeableRunContainer x); @Override MappeableContainer iandNot(MappeableArrayContainer x); @Override MappeableContainer iandNot(MappeableBitmapContainer x); @Override MappeableContainer iandNot(MappeableRunContainer x); @Override MappeableContainer inot(int rangeStart, int rangeEnd); @Override boolean intersects(MappeableArrayContainer x); @Override boolean intersects(MappeableBitmapContainer x); @Override boolean intersects(MappeableRunContainer x); @Override MappeableContainer ior(MappeableArrayContainer x); @Override MappeableContainer ior(MappeableBitmapContainer x); @Override MappeableContainer ior(MappeableRunContainer x); @Override // not thread-safe MappeableContainer iremove(int begin, int end); @Override boolean isFull(); static MappeableRunContainer full(); @Override Iterator<Character> iterator(); @Override MappeableContainer ixor(MappeableArrayContainer x); @Override MappeableContainer ixor(MappeableBitmapContainer x); @Override MappeableContainer ixor(MappeableRunContainer x); @Override MappeableContainer limit(int maxcardinality); @Override MappeableContainer not(int rangeStart, int rangeEnd); @Override int numberOfRuns(); @Override MappeableContainer or(MappeableArrayContainer x); @Override MappeableContainer or(MappeableBitmapContainer x); @Override MappeableContainer or(MappeableRunContainer x); @Override int rank(char lowbits); @Override void readExternal(ObjectInput in); @Override MappeableContainer remove(int begin, int end); @Override // not thread-safe MappeableContainer remove(char x); @Override MappeableContainer repairAfterLazy(); @Override MappeableContainer runOptimize(); @Override char select(int j); @Override int serializedSizeInBytes(); @Override Container toContainer(); char[] toCharArray(); @Override String toString(); @Override void trim(); @Override void writeExternal(ObjectOutput out); @Override MappeableContainer xor(MappeableArrayContainer x); @Override MappeableContainer xor(MappeableBitmapContainer x); @Override MappeableContainer xor(MappeableRunContainer x); @Override void forEach(char msb, IntConsumer ic); @Override int andCardinality(MappeableArrayContainer x); @Override int andCardinality(MappeableBitmapContainer x); @Override int andCardinality(MappeableRunContainer x); @Override MappeableBitmapContainer toBitmapContainer(); @Override int first(); @Override int last(); @Override int nextValue(char fromValue); @Override int previousValue(char fromValue); @Override int nextAbsentValue(char fromValue); @Override int previousAbsentValue(char fromValue); @Override boolean intersects(int minimum, int supremum); @Override boolean contains(int minimum, int supremum);  }