@Test public void testPreviousValue2() { RunContainer container = new RunContainer(new char[] { 64, 64, 200, 300, 5000, 200 }, 3); assertEquals(-1, container.previousValue((char)0)); assertEquals(-1, container.previousValue((char)63)); assertEquals(64, container.previousValue((char)64)); assertEquals(65, container.previousValue((char)65)); assertEquals(128, container.previousValue((char)128)); assertEquals(128, container.previousValue((char)129)); assertEquals(128, container.previousValue((char)199)); assertEquals(200, container.previousValue((char)200)); assertEquals(250, container.previousValue((char)250)); assertEquals(500, container.previousValue((char)2500)); assertEquals(5000, container.previousValue((char)5000)); assertEquals(5200, container.previousValue((char)5200)); }
@Override public int previousValue(char fromValue) { int index = unsignedInterleavedBinarySearch(valueslength, 0, nbrruns, fromValue); int effectiveIndex = index >= 0 ? index : -index - 2; if (effectiveIndex == -1) { return -1; } int startValue = (getValue(effectiveIndex)); int offset = (int) (fromValue) - startValue; int le = (getLength(effectiveIndex)); if (offset >= 0 && offset <= le) { return fromValue; } return startValue + le; }
RunContainer extends Container implements Cloneable { @Override public int previousValue(char fromValue) { int index = unsignedInterleavedBinarySearch(valueslength, 0, nbrruns, fromValue); int effectiveIndex = index >= 0 ? index : -index - 2; if (effectiveIndex == -1) { return -1; } int startValue = (getValue(effectiveIndex)); int offset = (int) (fromValue) - startValue; int le = (getLength(effectiveIndex)); if (offset >= 0 && offset <= le) { return fromValue; } return startValue + le; } }
RunContainer extends Container implements Cloneable { @Override public int previousValue(char fromValue) { int index = unsignedInterleavedBinarySearch(valueslength, 0, nbrruns, fromValue); int effectiveIndex = index >= 0 ? index : -index - 2; if (effectiveIndex == -1) { return -1; } int startValue = (getValue(effectiveIndex)); int offset = (int) (fromValue) - startValue; int le = (getLength(effectiveIndex)); if (offset >= 0 && offset <= le) { return fromValue; } return startValue + le; } 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 int previousValue(char fromValue) { int index = unsignedInterleavedBinarySearch(valueslength, 0, nbrruns, fromValue); int effectiveIndex = index >= 0 ? index : -index - 2; if (effectiveIndex == -1) { return -1; } int startValue = (getValue(effectiveIndex)); int offset = (int) (fromValue) - startValue; int le = (getLength(effectiveIndex)); if (offset >= 0 && offset <= le) { return fromValue; } return startValue + le; } 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 int previousValue(char fromValue) { int index = unsignedInterleavedBinarySearch(valueslength, 0, nbrruns, fromValue); int effectiveIndex = index >= 0 ? index : -index - 2; if (effectiveIndex == -1) { return -1; } int startValue = (getValue(effectiveIndex)); int offset = (int) (fromValue) - startValue; int le = (getLength(effectiveIndex)); if (offset >= 0 && offset <= le) { return fromValue; } return startValue + le; } 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();  }