@Test public void testTooSmallElement() { int[] numbers = new int[] { 1, 2, 3, 3, 3, 3, 3, 8, 9 }; int index = BinSearchFirstElement.binSearch(numbers, 0); assertEquals(0, index); }
public static int binSearch(int[] data, int value) { int l = -1, h = data.length; while (l + 1 != h) { int m = l + (h - l) / 2; if (data[m] < value) { l = m; } else { h = m; } } return h; }
BinSearchFirstElement { public static int binSearch(int[] data, int value) { int l = -1, h = data.length; while (l + 1 != h) { int m = l + (h - l) / 2; if (data[m] < value) { l = m; } else { h = m; } } return h; } }
BinSearchFirstElement { public static int binSearch(int[] data, int value) { int l = -1, h = data.length; while (l + 1 != h) { int m = l + (h - l) / 2; if (data[m] < value) { l = m; } else { h = m; } } return h; }  }
BinSearchFirstElement { public static int binSearch(int[] data, int value) { int l = -1, h = data.length; while (l + 1 != h) { int m = l + (h - l) / 2; if (data[m] < value) { l = m; } else { h = m; } } return h; }  static int binSearch(int[] data, int value); }
BinSearchFirstElement { public static int binSearch(int[] data, int value) { int l = -1, h = data.length; while (l + 1 != h) { int m = l + (h - l) / 2; if (data[m] < value) { l = m; } else { h = m; } } return h; }  static int binSearch(int[] data, int value);  }