code: private static int getLine0(int[] newlines, int index) {
          int j = Arrays.binarySearch(newlines, index);
          return j >= 0 ? j : -(j + 1);
      }
docs: returns the zero based input line number the character with the given index is found in