@Test public void iaddInvalidRange2() { assertThrows(IllegalArgumentException.class, () -> { Container rc = new RunContainer(); rc.iadd(0, 1 << 20); }); }
@Override public Container iadd(int begin, int end) { if(end == begin) { return this; } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } if (begin == end - 1) { add((char) begin); return this; } int bIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) begin); int eIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) (end - 1)); if (bIndex >= 0 && eIndex >= 0) { mergeValuesLength(bIndex, eIndex); return this; } else if (bIndex >= 0) { eIndex = -eIndex - 2; if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else if (eIndex >= 0) { bIndex = -bIndex - 2; if (bIndex >= 0) { if (valueLengthContains(begin - 1, bIndex)) { mergeValuesLength(bIndex, eIndex); return this; } } prependValueLength(begin, bIndex + 1); mergeValuesLength(bIndex + 1, eIndex); return this; } else { bIndex = -bIndex - 2; eIndex = -eIndex - 2; if (eIndex >= 0) { if (bIndex >= 0) { if (!valueLengthContains(begin - 1, bIndex)) { if (bIndex == eIndex) { if (canPrependValueLength(end - 1, eIndex + 1)) { prependValueLength(begin, eIndex + 1); return this; } makeRoomAtIndex(eIndex + 1); setValue(eIndex + 1, (char) begin); setLength(eIndex + 1, (char) (end - 1 - begin)); return this; } else { bIndex++; prependValueLength(begin, bIndex); } } } else { bIndex = 0; prependValueLength(begin, bIndex); } if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else { if (canPrependValueLength(end - 1, 0)) { prependValueLength(begin, 0); } else { makeRoomAtIndex(0); setValue(0, (char) begin); setLength(0, (char) (end - 1 - begin)); } return this; } } }
RunContainer extends Container implements Cloneable { @Override public Container iadd(int begin, int end) { if(end == begin) { return this; } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } if (begin == end - 1) { add((char) begin); return this; } int bIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) begin); int eIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) (end - 1)); if (bIndex >= 0 && eIndex >= 0) { mergeValuesLength(bIndex, eIndex); return this; } else if (bIndex >= 0) { eIndex = -eIndex - 2; if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else if (eIndex >= 0) { bIndex = -bIndex - 2; if (bIndex >= 0) { if (valueLengthContains(begin - 1, bIndex)) { mergeValuesLength(bIndex, eIndex); return this; } } prependValueLength(begin, bIndex + 1); mergeValuesLength(bIndex + 1, eIndex); return this; } else { bIndex = -bIndex - 2; eIndex = -eIndex - 2; if (eIndex >= 0) { if (bIndex >= 0) { if (!valueLengthContains(begin - 1, bIndex)) { if (bIndex == eIndex) { if (canPrependValueLength(end - 1, eIndex + 1)) { prependValueLength(begin, eIndex + 1); return this; } makeRoomAtIndex(eIndex + 1); setValue(eIndex + 1, (char) begin); setLength(eIndex + 1, (char) (end - 1 - begin)); return this; } else { bIndex++; prependValueLength(begin, bIndex); } } } else { bIndex = 0; prependValueLength(begin, bIndex); } if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else { if (canPrependValueLength(end - 1, 0)) { prependValueLength(begin, 0); } else { makeRoomAtIndex(0); setValue(0, (char) begin); setLength(0, (char) (end - 1 - begin)); } return this; } } } }
RunContainer extends Container implements Cloneable { @Override public Container iadd(int begin, int end) { if(end == begin) { return this; } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } if (begin == end - 1) { add((char) begin); return this; } int bIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) begin); int eIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) (end - 1)); if (bIndex >= 0 && eIndex >= 0) { mergeValuesLength(bIndex, eIndex); return this; } else if (bIndex >= 0) { eIndex = -eIndex - 2; if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else if (eIndex >= 0) { bIndex = -bIndex - 2; if (bIndex >= 0) { if (valueLengthContains(begin - 1, bIndex)) { mergeValuesLength(bIndex, eIndex); return this; } } prependValueLength(begin, bIndex + 1); mergeValuesLength(bIndex + 1, eIndex); return this; } else { bIndex = -bIndex - 2; eIndex = -eIndex - 2; if (eIndex >= 0) { if (bIndex >= 0) { if (!valueLengthContains(begin - 1, bIndex)) { if (bIndex == eIndex) { if (canPrependValueLength(end - 1, eIndex + 1)) { prependValueLength(begin, eIndex + 1); return this; } makeRoomAtIndex(eIndex + 1); setValue(eIndex + 1, (char) begin); setLength(eIndex + 1, (char) (end - 1 - begin)); return this; } else { bIndex++; prependValueLength(begin, bIndex); } } } else { bIndex = 0; prependValueLength(begin, bIndex); } if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else { if (canPrependValueLength(end - 1, 0)) { prependValueLength(begin, 0); } else { makeRoomAtIndex(0); setValue(0, (char) begin); setLength(0, (char) (end - 1 - begin)); } return this; } } } RunContainer(); protected  RunContainer(ArrayContainer arr, int nbrRuns);  RunContainer(final int firstOfRun, final int lastOfRun); protected  RunContainer(BitmapContainer bc, int nbrRuns);  RunContainer(final int capacity); private  RunContainer(int nbrruns, char[] valueslength);  RunContainer(MappeableRunContainer bc);  RunContainer(final char[] array, final int numRuns); }
RunContainer extends Container implements Cloneable { @Override public Container iadd(int begin, int end) { if(end == begin) { return this; } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } if (begin == end - 1) { add((char) begin); return this; } int bIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) begin); int eIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) (end - 1)); if (bIndex >= 0 && eIndex >= 0) { mergeValuesLength(bIndex, eIndex); return this; } else if (bIndex >= 0) { eIndex = -eIndex - 2; if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else if (eIndex >= 0) { bIndex = -bIndex - 2; if (bIndex >= 0) { if (valueLengthContains(begin - 1, bIndex)) { mergeValuesLength(bIndex, eIndex); return this; } } prependValueLength(begin, bIndex + 1); mergeValuesLength(bIndex + 1, eIndex); return this; } else { bIndex = -bIndex - 2; eIndex = -eIndex - 2; if (eIndex >= 0) { if (bIndex >= 0) { if (!valueLengthContains(begin - 1, bIndex)) { if (bIndex == eIndex) { if (canPrependValueLength(end - 1, eIndex + 1)) { prependValueLength(begin, eIndex + 1); return this; } makeRoomAtIndex(eIndex + 1); setValue(eIndex + 1, (char) begin); setLength(eIndex + 1, (char) (end - 1 - begin)); return this; } else { bIndex++; prependValueLength(begin, bIndex); } } } else { bIndex = 0; prependValueLength(begin, bIndex); } if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else { if (canPrependValueLength(end - 1, 0)) { prependValueLength(begin, 0); } else { makeRoomAtIndex(0); setValue(0, (char) begin); setLength(0, (char) (end - 1 - begin)); } return this; } } } RunContainer(); protected  RunContainer(ArrayContainer arr, int nbrRuns);  RunContainer(final int firstOfRun, final int lastOfRun); protected  RunContainer(BitmapContainer bc, int nbrRuns);  RunContainer(final int capacity); private  RunContainer(int nbrruns, char[] valueslength);  RunContainer(MappeableRunContainer bc);  RunContainer(final char[] array, final int numRuns); @Override Container add(int begin, int end); @Override Container add(char k); @Override Container and(ArrayContainer x); @Override Container and(BitmapContainer x); @Override Container and(RunContainer x); @Override int andCardinality(ArrayContainer x); @Override int andCardinality(BitmapContainer x); @Override int andCardinality(RunContainer x); @Override Container andNot(ArrayContainer x); @Override Container andNot(BitmapContainer x); @Override Container andNot(RunContainer x); @Override void clear(); @Override Container clone(); @Override boolean isEmpty(); @Override boolean contains(char x); @Override boolean contains(int minimum, int supremum); @Override void deserialize(DataInput in); @Override boolean equals(Object o); @Override void fillLeastSignificant16bits(int[] x, int i, int mask); @Override Container flip(char x); @Override int getArraySizeInBytes(); @Override int getCardinality(); char getLength(int index); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override PeekableCharRankIterator getCharRankIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); char getValue(int index); @Override int hashCode(); @Override Container iadd(int begin, int end); @Override Container iand(ArrayContainer x); @Override Container iand(BitmapContainer x); @Override Container iand(RunContainer x); @Override Container iandNot(ArrayContainer x); @Override Container iandNot(BitmapContainer x); @Override Container iandNot(RunContainer x); @Override Container inot(int rangeStart, int rangeEnd); @Override boolean intersects(ArrayContainer x); @Override boolean intersects(BitmapContainer x); @Override boolean intersects(RunContainer x); @Override boolean intersects(int minimum, int supremum); @Override Container ior(ArrayContainer x); @Override Container ior(BitmapContainer x); @Override Container ior(RunContainer x); @Override Container iremove(int begin, int end); @Override boolean isFull(); static RunContainer full(); @Override Iterator<Character> iterator(); @Override Container ixor(ArrayContainer x); @Override Container ixor(BitmapContainer x); @Override Container ixor(RunContainer x); @Override Container limit(int maxcardinality); @Override Container not(int rangeStart, int rangeEnd); @Override int numberOfRuns(); @Override Container or(ArrayContainer x); @Override Container or(BitmapContainer x); @Override Container or(RunContainer x); @Override int rank(char lowbits); @Override void readExternal(ObjectInput in); @Override Container remove(int begin, int end); @Override Container remove(char x); @Override Container repairAfterLazy(); @Override Container runOptimize(); @Override char select(int j); @Override void serialize(DataOutput out); @Override int serializedSizeInBytes(); @Override MappeableContainer toMappeableContainer(); CharBuffer toCharBuffer(); @Override String toString(); @Override void trim(); @Override void writeArray(DataOutput out); @Override void writeArray(ByteBuffer buffer); @Override void writeExternal(ObjectOutput out); @Override Container xor(ArrayContainer x); @Override Container xor(BitmapContainer x); @Override Container xor(RunContainer x); @Override void forEach(char msb, IntConsumer ic); @Override BitmapContainer toBitmapContainer(); @Override int nextValue(char fromValue); @Override int previousValue(char fromValue); @Override int nextAbsentValue(char fromValue); @Override int previousAbsentValue(char fromValue); @Override int first(); @Override int last(); }
RunContainer extends Container implements Cloneable { @Override public Container iadd(int begin, int end) { if(end == begin) { return this; } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } if (begin == end - 1) { add((char) begin); return this; } int bIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) begin); int eIndex = unsignedInterleavedBinarySearch(this.valueslength, 0, this.nbrruns, (char) (end - 1)); if (bIndex >= 0 && eIndex >= 0) { mergeValuesLength(bIndex, eIndex); return this; } else if (bIndex >= 0) { eIndex = -eIndex - 2; if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else if (eIndex >= 0) { bIndex = -bIndex - 2; if (bIndex >= 0) { if (valueLengthContains(begin - 1, bIndex)) { mergeValuesLength(bIndex, eIndex); return this; } } prependValueLength(begin, bIndex + 1); mergeValuesLength(bIndex + 1, eIndex); return this; } else { bIndex = -bIndex - 2; eIndex = -eIndex - 2; if (eIndex >= 0) { if (bIndex >= 0) { if (!valueLengthContains(begin - 1, bIndex)) { if (bIndex == eIndex) { if (canPrependValueLength(end - 1, eIndex + 1)) { prependValueLength(begin, eIndex + 1); return this; } makeRoomAtIndex(eIndex + 1); setValue(eIndex + 1, (char) begin); setLength(eIndex + 1, (char) (end - 1 - begin)); return this; } else { bIndex++; prependValueLength(begin, bIndex); } } } else { bIndex = 0; prependValueLength(begin, bIndex); } if (canPrependValueLength(end - 1, eIndex + 1)) { mergeValuesLength(bIndex, eIndex + 1); return this; } appendValueLength(end - 1, eIndex); mergeValuesLength(bIndex, eIndex); return this; } else { if (canPrependValueLength(end - 1, 0)) { prependValueLength(begin, 0); } else { makeRoomAtIndex(0); setValue(0, (char) begin); setLength(0, (char) (end - 1 - begin)); } return this; } } } RunContainer(); protected  RunContainer(ArrayContainer arr, int nbrRuns);  RunContainer(final int firstOfRun, final int lastOfRun); protected  RunContainer(BitmapContainer bc, int nbrRuns);  RunContainer(final int capacity); private  RunContainer(int nbrruns, char[] valueslength);  RunContainer(MappeableRunContainer bc);  RunContainer(final char[] array, final int numRuns); @Override Container add(int begin, int end); @Override Container add(char k); @Override Container and(ArrayContainer x); @Override Container and(BitmapContainer x); @Override Container and(RunContainer x); @Override int andCardinality(ArrayContainer x); @Override int andCardinality(BitmapContainer x); @Override int andCardinality(RunContainer x); @Override Container andNot(ArrayContainer x); @Override Container andNot(BitmapContainer x); @Override Container andNot(RunContainer x); @Override void clear(); @Override Container clone(); @Override boolean isEmpty(); @Override boolean contains(char x); @Override boolean contains(int minimum, int supremum); @Override void deserialize(DataInput in); @Override boolean equals(Object o); @Override void fillLeastSignificant16bits(int[] x, int i, int mask); @Override Container flip(char x); @Override int getArraySizeInBytes(); @Override int getCardinality(); char getLength(int index); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override PeekableCharRankIterator getCharRankIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); char getValue(int index); @Override int hashCode(); @Override Container iadd(int begin, int end); @Override Container iand(ArrayContainer x); @Override Container iand(BitmapContainer x); @Override Container iand(RunContainer x); @Override Container iandNot(ArrayContainer x); @Override Container iandNot(BitmapContainer x); @Override Container iandNot(RunContainer x); @Override Container inot(int rangeStart, int rangeEnd); @Override boolean intersects(ArrayContainer x); @Override boolean intersects(BitmapContainer x); @Override boolean intersects(RunContainer x); @Override boolean intersects(int minimum, int supremum); @Override Container ior(ArrayContainer x); @Override Container ior(BitmapContainer x); @Override Container ior(RunContainer x); @Override Container iremove(int begin, int end); @Override boolean isFull(); static RunContainer full(); @Override Iterator<Character> iterator(); @Override Container ixor(ArrayContainer x); @Override Container ixor(BitmapContainer x); @Override Container ixor(RunContainer x); @Override Container limit(int maxcardinality); @Override Container not(int rangeStart, int rangeEnd); @Override int numberOfRuns(); @Override Container or(ArrayContainer x); @Override Container or(BitmapContainer x); @Override Container or(RunContainer x); @Override int rank(char lowbits); @Override void readExternal(ObjectInput in); @Override Container remove(int begin, int end); @Override Container remove(char x); @Override Container repairAfterLazy(); @Override Container runOptimize(); @Override char select(int j); @Override void serialize(DataOutput out); @Override int serializedSizeInBytes(); @Override MappeableContainer toMappeableContainer(); CharBuffer toCharBuffer(); @Override String toString(); @Override void trim(); @Override void writeArray(DataOutput out); @Override void writeArray(ByteBuffer buffer); @Override void writeExternal(ObjectOutput out); @Override Container xor(ArrayContainer x); @Override Container xor(BitmapContainer x); @Override Container xor(RunContainer x); @Override void forEach(char msb, IntConsumer ic); @Override BitmapContainer toBitmapContainer(); @Override int nextValue(char fromValue); @Override int previousValue(char fromValue); @Override int nextAbsentValue(char fromValue); @Override int previousAbsentValue(char fromValue); @Override int first(); @Override int last();  }