### Question:
PercentileBuckets { public static int indexOf(long v) { if (v <= 0) { return 0; } else if (v <= 4) { return (int) v; } else { int lz = Long.numberOfLeadingZeros(v); int shift = 64 - lz - 1; long prevPowerOf2 = (v >> shift) << shift; long prevPowerOf4 = prevPowerOf2; if (shift % 2 != 0) { shift--; prevPowerOf4 = prevPowerOf2 >> 1; } long base = prevPowerOf4; long delta = base / 3; int offset = (int) ((v - base) / delta); int pos = offset + POWER_OF_4_INDEX[shift / 2]; return (pos >= BUCKET_VALUES.length - 1) ? BUCKET_VALUES.length - 1 : pos + 1; } } private  PercentileBuckets(); static long[] asArray(); static T[] map(Class<T> c, Function<Long, T> f); static long get(int i); static int length(); static int indexOf(long v); static long bucket(long v); static void percentiles(long[] counts, double[] pcts, double[] results); static double percentile(long[] counts, double p);  }### Answer:
@Test public void indexOf() { Assertions.assertEquals(0, PercentileBuckets.indexOf(-1)); Assertions.assertEquals(0, PercentileBuckets.indexOf(0)); Assertions.assertEquals(1, PercentileBuckets.indexOf(1)); Assertions.assertEquals(2, PercentileBuckets.indexOf(2)); Assertions.assertEquals(3, PercentileBuckets.indexOf(3)); Assertions.assertEquals(4, PercentileBuckets.indexOf(4)); Assertions.assertEquals(25, PercentileBuckets.indexOf(87)); Assertions.assertEquals(PercentileBuckets.length() - 1, PercentileBuckets.indexOf(Long.MAX_VALUE)); }