ArrayUtils { public static int[] fuzzyIntervalSearch(final float[] base, final float startValue, final float endValue) { if (base == null || base.length == 0) return null; if (startValue > endValue || endValue < base[0] || startValue > base[base.length - 1]) return null; return searchStartAndEnd(base, startValue, endValue, 0, base.length - 1); }  static int[] fuzzyIntervalSearch(final float[] base, final float startValue, final float endValue); static int fuzzySearch(final float[] base, final float value, final boolean orGreater);  }
@Test public void testFuzzyIntervalSearch() { final float[] base = new float[] { 1, 4, 4, 5, 7.3f, 8, 10, 23.4f, 23.4f, 34 }; final float[] nullBase = null; final float[] emptyBase = new float[0]; assertNull(ArrayUtils.fuzzyIntervalSearch(nullBase, 4, 23)); assertNull(ArrayUtils.fuzzyIntervalSearch(emptyBase, 4, 23)); assertNull(ArrayUtils.fuzzyIntervalSearch(base, 10, 4)); assertNull(ArrayUtils.fuzzyIntervalSearch(base, -4, 0.5f)); assertNull(ArrayUtils.fuzzyIntervalSearch(base, 35, 90)); assertArrayEquals(new int[] { 4, 4 }, ArrayUtils.fuzzyIntervalSearch(base, 7, 7.9f)); assertArrayEquals(new int[] { 1, 2 }, ArrayUtils.fuzzyIntervalSearch(base, 2.3f, 4.5f)); assertArrayEquals(new int[] { 1, 8 }, ArrayUtils.fuzzyIntervalSearch(base, 4, 23.4f)); assertArrayEquals(new int[] { 0, 2 }, ArrayUtils.fuzzyIntervalSearch(base, 1, 4)); assertArrayEquals(new int[] { 1, 8 }, ArrayUtils.fuzzyIntervalSearch(base, 3.2f, 24.5f)); assertArrayEquals(new int[] { 0, 2 }, ArrayUtils.fuzzyIntervalSearch(base, 0.1f, 4.99f)); assertArrayEquals(new int[] { 0, base.length - 1 }, ArrayUtils.fuzzyIntervalSearch(base, -1, 90)); assertArrayEquals(new int[] { 0, 4 }, ArrayUtils.fuzzyIntervalSearch(base, -34.3f, 7.99999f)); assertArrayEquals(new int[] { 7, base.length - 1 }, ArrayUtils.fuzzyIntervalSearch(base, 23.1f, 99.9999f)); }