@Test public void addInvalidRange() { assertThrows(IllegalArgumentException.class, () -> { Container ac = new ArrayContainer(); ac.add(13, 1); }); }
@Override public Container add(int begin, int end) { if(end == begin) { return clone(); } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } int indexstart = Util.unsignedBinarySearch(content, 0, cardinality, (char) begin); if (indexstart < 0) { indexstart = -indexstart - 1; } int indexend = Util.unsignedBinarySearch(content, 0, cardinality, (char) (end - 1)); if (indexend < 0) { indexend = -indexend - 1; } else { indexend++; } int rangelength = end - begin; int newcardinality = indexstart + (cardinality - indexend) + rangelength; if (newcardinality > DEFAULT_MAX_SIZE) { BitmapContainer a = this.toBitmapContainer(); return a.iadd(begin, end); } ArrayContainer answer = new ArrayContainer(newcardinality, content); System.arraycopy(content, indexend, answer.content, indexstart + rangelength, cardinality - indexend); for (int k = 0; k < rangelength; ++k) { answer.content[k + indexstart] = (char) (begin + k); } answer.cardinality = newcardinality; return answer; }
ArrayContainer extends Container implements Cloneable { @Override public Container add(int begin, int end) { if(end == begin) { return clone(); } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } int indexstart = Util.unsignedBinarySearch(content, 0, cardinality, (char) begin); if (indexstart < 0) { indexstart = -indexstart - 1; } int indexend = Util.unsignedBinarySearch(content, 0, cardinality, (char) (end - 1)); if (indexend < 0) { indexend = -indexend - 1; } else { indexend++; } int rangelength = end - begin; int newcardinality = indexstart + (cardinality - indexend) + rangelength; if (newcardinality > DEFAULT_MAX_SIZE) { BitmapContainer a = this.toBitmapContainer(); return a.iadd(begin, end); } ArrayContainer answer = new ArrayContainer(newcardinality, content); System.arraycopy(content, indexend, answer.content, indexstart + rangelength, cardinality - indexend); for (int k = 0; k < rangelength; ++k) { answer.content[k + indexstart] = (char) (begin + k); } answer.cardinality = newcardinality; return answer; } }
ArrayContainer extends Container implements Cloneable { @Override public Container add(int begin, int end) { if(end == begin) { return clone(); } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } int indexstart = Util.unsignedBinarySearch(content, 0, cardinality, (char) begin); if (indexstart < 0) { indexstart = -indexstart - 1; } int indexend = Util.unsignedBinarySearch(content, 0, cardinality, (char) (end - 1)); if (indexend < 0) { indexend = -indexend - 1; } else { indexend++; } int rangelength = end - begin; int newcardinality = indexstart + (cardinality - indexend) + rangelength; if (newcardinality > DEFAULT_MAX_SIZE) { BitmapContainer a = this.toBitmapContainer(); return a.iadd(begin, end); } ArrayContainer answer = new ArrayContainer(newcardinality, content); System.arraycopy(content, indexend, answer.content, indexstart + rangelength, cardinality - indexend); for (int k = 0; k < rangelength; ++k) { answer.content[k + indexstart] = (char) (begin + k); } answer.cardinality = newcardinality; return answer; } ArrayContainer();  ArrayContainer(final int capacity);  ArrayContainer(final int firstOfRun, final int lastOfRun);  ArrayContainer(int newCard, char[] newContent);  ArrayContainer(MappeableArrayContainer bc);  ArrayContainer(char[] newContent); }
ArrayContainer extends Container implements Cloneable { @Override public Container add(int begin, int end) { if(end == begin) { return clone(); } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } int indexstart = Util.unsignedBinarySearch(content, 0, cardinality, (char) begin); if (indexstart < 0) { indexstart = -indexstart - 1; } int indexend = Util.unsignedBinarySearch(content, 0, cardinality, (char) (end - 1)); if (indexend < 0) { indexend = -indexend - 1; } else { indexend++; } int rangelength = end - begin; int newcardinality = indexstart + (cardinality - indexend) + rangelength; if (newcardinality > DEFAULT_MAX_SIZE) { BitmapContainer a = this.toBitmapContainer(); return a.iadd(begin, end); } ArrayContainer answer = new ArrayContainer(newcardinality, content); System.arraycopy(content, indexend, answer.content, indexstart + rangelength, cardinality - indexend); for (int k = 0; k < rangelength; ++k) { answer.content[k + indexstart] = (char) (begin + k); } answer.cardinality = newcardinality; return answer; } ArrayContainer();  ArrayContainer(final int capacity);  ArrayContainer(final int firstOfRun, final int lastOfRun);  ArrayContainer(int newCard, char[] newContent);  ArrayContainer(MappeableArrayContainer bc);  ArrayContainer(char[] newContent); static ArrayContainer empty(); @Override Container add(int begin, int end); @Override Container add(final char x); @Override ArrayContainer and(final ArrayContainer value2); @Override Container and(BitmapContainer x); @Override // see andNot for an approach that might be better. Container and(RunContainer x); @Override int andCardinality(final ArrayContainer value2); @Override int andCardinality(BitmapContainer x); @Override // see andNot for an approach that might be better. int andCardinality(RunContainer x); @Override ArrayContainer andNot(final ArrayContainer value2); @Override ArrayContainer andNot(BitmapContainer value2); @Override ArrayContainer andNot(RunContainer x); @Override void clear(); @Override ArrayContainer clone(); @Override boolean isEmpty(); @Override boolean isFull(); @Override boolean contains(final 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(); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override PeekableCharRankIterator getCharRankIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); @Override int hashCode(); @Override Container iadd(int begin, int end); @Override ArrayContainer iand(final ArrayContainer value2); @Override Container iand(BitmapContainer value2); @Override Container iand(RunContainer x); @Override ArrayContainer iandNot(final ArrayContainer value2); @Override ArrayContainer iandNot(BitmapContainer value2); @Override Container iandNot(RunContainer x); @Override Container inot(final int firstOfRange, final int lastOfRange); @Override boolean intersects(ArrayContainer value2); @Override boolean intersects(BitmapContainer x); @Override boolean intersects(RunContainer x); @Override boolean intersects(int minimum, int supremum); @Override Container ior(final ArrayContainer value2); @Override Container ior(BitmapContainer x); @Override Container ior(RunContainer x); @Override Container iremove(int begin, int end); @Override Iterator<Character> iterator(); @Override Container ixor(final ArrayContainer value2); @Override Container ixor(BitmapContainer x); @Override Container ixor(RunContainer x); @Override Container limit(int maxcardinality); @Override Container not(final int firstOfRange, final int lastOfRange); @Override Container or(final ArrayContainer value2); @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(final char x); @Override Container repairAfterLazy(); @Override Container runOptimize(); @Override char select(int j); @Override void serialize(DataOutput out); @Override int serializedSizeInBytes(); @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(); @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(final ArrayContainer value2); @Override Container xor(BitmapContainer x); @Override Container xor(RunContainer x); @Override void forEach(char msb, IntConsumer ic); }
ArrayContainer extends Container implements Cloneable { @Override public Container add(int begin, int end) { if(end == begin) { return clone(); } if ((begin > end) || (end > (1 << 16))) { throw new IllegalArgumentException("Invalid range [" + begin + "," + end + ")"); } int indexstart = Util.unsignedBinarySearch(content, 0, cardinality, (char) begin); if (indexstart < 0) { indexstart = -indexstart - 1; } int indexend = Util.unsignedBinarySearch(content, 0, cardinality, (char) (end - 1)); if (indexend < 0) { indexend = -indexend - 1; } else { indexend++; } int rangelength = end - begin; int newcardinality = indexstart + (cardinality - indexend) + rangelength; if (newcardinality > DEFAULT_MAX_SIZE) { BitmapContainer a = this.toBitmapContainer(); return a.iadd(begin, end); } ArrayContainer answer = new ArrayContainer(newcardinality, content); System.arraycopy(content, indexend, answer.content, indexstart + rangelength, cardinality - indexend); for (int k = 0; k < rangelength; ++k) { answer.content[k + indexstart] = (char) (begin + k); } answer.cardinality = newcardinality; return answer; } ArrayContainer();  ArrayContainer(final int capacity);  ArrayContainer(final int firstOfRun, final int lastOfRun);  ArrayContainer(int newCard, char[] newContent);  ArrayContainer(MappeableArrayContainer bc);  ArrayContainer(char[] newContent); static ArrayContainer empty(); @Override Container add(int begin, int end); @Override Container add(final char x); @Override ArrayContainer and(final ArrayContainer value2); @Override Container and(BitmapContainer x); @Override // see andNot for an approach that might be better. Container and(RunContainer x); @Override int andCardinality(final ArrayContainer value2); @Override int andCardinality(BitmapContainer x); @Override // see andNot for an approach that might be better. int andCardinality(RunContainer x); @Override ArrayContainer andNot(final ArrayContainer value2); @Override ArrayContainer andNot(BitmapContainer value2); @Override ArrayContainer andNot(RunContainer x); @Override void clear(); @Override ArrayContainer clone(); @Override boolean isEmpty(); @Override boolean isFull(); @Override boolean contains(final 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(); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override PeekableCharRankIterator getCharRankIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); @Override int hashCode(); @Override Container iadd(int begin, int end); @Override ArrayContainer iand(final ArrayContainer value2); @Override Container iand(BitmapContainer value2); @Override Container iand(RunContainer x); @Override ArrayContainer iandNot(final ArrayContainer value2); @Override ArrayContainer iandNot(BitmapContainer value2); @Override Container iandNot(RunContainer x); @Override Container inot(final int firstOfRange, final int lastOfRange); @Override boolean intersects(ArrayContainer value2); @Override boolean intersects(BitmapContainer x); @Override boolean intersects(RunContainer x); @Override boolean intersects(int minimum, int supremum); @Override Container ior(final ArrayContainer value2); @Override Container ior(BitmapContainer x); @Override Container ior(RunContainer x); @Override Container iremove(int begin, int end); @Override Iterator<Character> iterator(); @Override Container ixor(final ArrayContainer value2); @Override Container ixor(BitmapContainer x); @Override Container ixor(RunContainer x); @Override Container limit(int maxcardinality); @Override Container not(final int firstOfRange, final int lastOfRange); @Override Container or(final ArrayContainer value2); @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(final char x); @Override Container repairAfterLazy(); @Override Container runOptimize(); @Override char select(int j); @Override void serialize(DataOutput out); @Override int serializedSizeInBytes(); @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(); @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(final ArrayContainer value2); @Override Container xor(BitmapContainer x); @Override Container xor(RunContainer x); @Override void forEach(char msb, IntConsumer ic);  }