@Test public void testAdvanceUntil() { char[] data = fromShorts(new short[]{0, 3, 16, 18, 21, 29, 30,-342}); assertEquals(1, Util.advanceUntil(data, -1, data.length, (char) 3)); assertEquals(5, Util.advanceUntil(data, -1, data.length, (char) 28)); assertEquals(5, Util.advanceUntil(data, -1, data.length, (char) 29)); assertEquals(7, Util.advanceUntil(data, -1, data.length, (char) -342)); }
public static int advanceUntil(char[] array, int pos, int length, char min) { int lower = pos + 1; if (lower >= length || (array[lower]) >= (int) (min)) { return lower; } int spansize = 1; while (lower + spansize < length && (array[lower + spansize]) < (int) (min)) { spansize *= 2; } int upper = (lower + spansize < length) ? lower + spansize : length - 1; if (array[upper] == min) { return upper; } if ((array[upper]) < (int) (min)) { return length; } lower += (spansize >>> 1); while (lower + 1 != upper) { int mid = (lower + upper) >>> 1; char arraymid = array[mid]; if (arraymid == min) { return mid; } else if ((arraymid) < (int) (min)) { lower = mid; } else { upper = mid; } } return upper; }
Util { public static int advanceUntil(char[] array, int pos, int length, char min) { int lower = pos + 1; if (lower >= length || (array[lower]) >= (int) (min)) { return lower; } int spansize = 1; while (lower + spansize < length && (array[lower + spansize]) < (int) (min)) { spansize *= 2; } int upper = (lower + spansize < length) ? lower + spansize : length - 1; if (array[upper] == min) { return upper; } if ((array[upper]) < (int) (min)) { return length; } lower += (spansize >>> 1); while (lower + 1 != upper) { int mid = (lower + upper) >>> 1; char arraymid = array[mid]; if (arraymid == min) { return mid; } else if ((arraymid) < (int) (min)) { lower = mid; } else { upper = mid; } } return upper; } }
Util { public static int advanceUntil(char[] array, int pos, int length, char min) { int lower = pos + 1; if (lower >= length || (array[lower]) >= (int) (min)) { return lower; } int spansize = 1; while (lower + spansize < length && (array[lower + spansize]) < (int) (min)) { spansize *= 2; } int upper = (lower + spansize < length) ? lower + spansize : length - 1; if (array[upper] == min) { return upper; } if ((array[upper]) < (int) (min)) { return length; } lower += (spansize >>> 1); while (lower + 1 != upper) { int mid = (lower + upper) >>> 1; char arraymid = array[mid]; if (arraymid == min) { return mid; } else if ((arraymid) < (int) (min)) { lower = mid; } else { upper = mid; } } return upper; } private  Util(); }
Util { public static int advanceUntil(char[] array, int pos, int length, char min) { int lower = pos + 1; if (lower >= length || (array[lower]) >= (int) (min)) { return lower; } int spansize = 1; while (lower + spansize < length && (array[lower + spansize]) < (int) (min)) { spansize *= 2; } int upper = (lower + spansize < length) ? lower + spansize : length - 1; if (array[upper] == min) { return upper; } if ((array[upper]) < (int) (min)) { return length; } lower += (spansize >>> 1); while (lower + 1 != upper) { int mid = (lower + upper) >>> 1; char arraymid = array[mid]; if (arraymid == min) { return mid; } else if ((arraymid) < (int) (min)) { lower = mid; } else { upper = mid; } } return upper; } private  Util(); static Container[] addOffset(Container source, char offsets); static int advanceUntil(char[] array, int pos, int length, char min); static int iterateUntil(char[] array, int pos, int length, int min); static void fillArrayAND(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayANDNOT(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayXOR(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void flipBitmapRange(long[] bitmap, int start, int end); @Deprecated static int cardinalityInBitmapWordRange(long[] bitmap, int start, int end); static int cardinalityInBitmapRange(long[] bitmap, int start, int end); static int maxLowBitAsInteger(); static void resetBitmapRange(long[] bitmap, int start, int end); static int intersectArrayIntoBitmap(long[] bitmap, char[] array, int length); static int select(long w, int j); static void setBitmapRange(long[] bitmap, int start, int end); @Deprecated static int setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int flipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int resetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); static int unsignedBinarySearch(final char[] array, final int begin, final int end,
      final char k); static int unsignedDifference(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static int unsignedDifference(CharIterator set1, CharIterator set2,
                                       final char[] buffer); static int unsignedExclusiveUnion2by2(final char[] set1, final int length1,
      final char[] set2, final int length2, final char[] buffer); static int unsignedIntersect2by2(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2); static int unsignedLocalIntersect2by2Cardinality(final char[] set1, final int length1,
      final char[] set2, final int length2); static int unsignedUnion2by2(
          final char[] set1, final int offset1, final int length1,
          final char[] set2, final int offset2, final int length2,
          final char[] buffer); static long toUnsignedLong(int x); static void partialRadixSort(int[] data); }
Util { public static int advanceUntil(char[] array, int pos, int length, char min) { int lower = pos + 1; if (lower >= length || (array[lower]) >= (int) (min)) { return lower; } int spansize = 1; while (lower + spansize < length && (array[lower + spansize]) < (int) (min)) { spansize *= 2; } int upper = (lower + spansize < length) ? lower + spansize : length - 1; if (array[upper] == min) { return upper; } if ((array[upper]) < (int) (min)) { return length; } lower += (spansize >>> 1); while (lower + 1 != upper) { int mid = (lower + upper) >>> 1; char arraymid = array[mid]; if (arraymid == min) { return mid; } else if ((arraymid) < (int) (min)) { lower = mid; } else { upper = mid; } } return upper; } private  Util(); static Container[] addOffset(Container source, char offsets); static int advanceUntil(char[] array, int pos, int length, char min); static int iterateUntil(char[] array, int pos, int length, int min); static void fillArrayAND(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayANDNOT(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayXOR(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void flipBitmapRange(long[] bitmap, int start, int end); @Deprecated static int cardinalityInBitmapWordRange(long[] bitmap, int start, int end); static int cardinalityInBitmapRange(long[] bitmap, int start, int end); static int maxLowBitAsInteger(); static void resetBitmapRange(long[] bitmap, int start, int end); static int intersectArrayIntoBitmap(long[] bitmap, char[] array, int length); static int select(long w, int j); static void setBitmapRange(long[] bitmap, int start, int end); @Deprecated static int setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int flipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int resetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); static int unsignedBinarySearch(final char[] array, final int begin, final int end,
      final char k); static int unsignedDifference(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static int unsignedDifference(CharIterator set1, CharIterator set2,
                                       final char[] buffer); static int unsignedExclusiveUnion2by2(final char[] set1, final int length1,
      final char[] set2, final int length2, final char[] buffer); static int unsignedIntersect2by2(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2); static int unsignedLocalIntersect2by2Cardinality(final char[] set1, final int length1,
      final char[] set2, final int length2); static int unsignedUnion2by2(
          final char[] set1, final int offset1, final int length1,
          final char[] set2, final int offset2, final int length2,
          final char[] buffer); static long toUnsignedLong(int x); static void partialRadixSort(int[] data); static final boolean USE_HYBRID_BINSEARCH; }