@Test public void binarySearchValueOrHigher2() { ListNumber values = new ArrayDouble(1,2,2,2,2,2,2,2,2,2,3); assertThat(ListNumbers.binarySearchValueOrHigher(values, 2), equalTo(9)); }
public static int binarySearchValueOrHigher(ListNumber values, double value) { if (value <= values.getDouble(0)) { return 0; } if (value >= values.getDouble(values.size() -1)) { return values.size() - 1; } int index = binarySearch(0, values.size() - 1, values, value); while (index != values.size() - 1 && value > values.getDouble(index)) { index++; } while (index != values.size() - 1 && value == values.getDouble(index + 1)) { index++; } return index; }
ListNumbers { public static int binarySearchValueOrHigher(ListNumber values, double value) { if (value <= values.getDouble(0)) { return 0; } if (value >= values.getDouble(values.size() -1)) { return values.size() - 1; } int index = binarySearch(0, values.size() - 1, values, value); while (index != values.size() - 1 && value > values.getDouble(index)) { index++; } while (index != values.size() - 1 && value == values.getDouble(index + 1)) { index++; } return index; } }
ListNumbers { public static int binarySearchValueOrHigher(ListNumber values, double value) { if (value <= values.getDouble(0)) { return 0; } if (value >= values.getDouble(values.size() -1)) { return values.size() - 1; } int index = binarySearch(0, values.size() - 1, values, value); while (index != values.size() - 1 && value > values.getDouble(index)) { index++; } while (index != values.size() - 1 && value == values.getDouble(index + 1)) { index++; } return index; }  }
ListNumbers { public static int binarySearchValueOrHigher(ListNumber values, double value) { if (value <= values.getDouble(0)) { return 0; } if (value >= values.getDouble(values.size() -1)) { return values.size() - 1; } int index = binarySearch(0, values.size() - 1, values, value); while (index != values.size() - 1 && value > values.getDouble(index)) { index++; } while (index != values.size() - 1 && value == values.getDouble(index + 1)) { index++; } return index; }  static SortedListView sortedView(ListNumber values); static SortedListView sortedView(ListNumber values, ListInt indexes); static int binarySearchValueOrLower(ListNumber values, double value); static int binarySearchValueOrHigher(ListNumber values, double value); static ListNumber linearListFromRange(final double minValue, final double maxValue, final int size); static ListNumber linearList(final double initialValue, final double increment, final int size); static boolean isLinear(ListNumber listNumber); static ListNumber toListNumber(Object primitiveArray); static ListNumber listView(ListNumber list, ListInt indexes); }
ListNumbers { public static int binarySearchValueOrHigher(ListNumber values, double value) { if (value <= values.getDouble(0)) { return 0; } if (value >= values.getDouble(values.size() -1)) { return values.size() - 1; } int index = binarySearch(0, values.size() - 1, values, value); while (index != values.size() - 1 && value > values.getDouble(index)) { index++; } while (index != values.size() - 1 && value == values.getDouble(index + 1)) { index++; } return index; }  static SortedListView sortedView(ListNumber values); static SortedListView sortedView(ListNumber values, ListInt indexes); static int binarySearchValueOrLower(ListNumber values, double value); static int binarySearchValueOrHigher(ListNumber values, double value); static ListNumber linearListFromRange(final double minValue, final double maxValue, final int size); static ListNumber linearList(final double initialValue, final double increment, final int size); static boolean isLinear(ListNumber listNumber); static ListNumber toListNumber(Object primitiveArray); static ListNumber listView(ListNumber list, ListInt indexes);  }