public static int binarySearch(Sortable data) {
    int value = data.size();
    int lower = 0;
    int upper = data.size();
    while (lower < upper) {
      int mid = (lower + upper) >> 1;
      if (data.isLess(mid, value)) {
        lower = mid + 1;
      } else {
        upper = mid;
      }
    }
    return lower;
  }
@Test
  public void testSearch() {
    int[] a = new int[] { 1, 2, 4, 4, 4, 5, 0 };
    SimpleSortable sortable = new SimpleSortable(a, a.length - 1);
    // search 4
    a[a.length - 1] = 4;
    assertThat(DataUtils.binarySearch(sortable), is(2));
    // search 5
    a[a.length - 1] = 5;
    assertThat(DataUtils.binarySearch(sortable), is(5));
    // search -5
    a[a.length - 1] = -5;
    assertThat(DataUtils.binarySearch(sortable), is(0));
    // search 10
    a[a.length - 1] = 10;
    assertThat(DataUtils.binarySearch(sortable), is(6));
    // search 3
    a[a.length - 1] = 3;
    assertThat(DataUtils.binarySearch(sortable), is(2));
  }