private int insertionIndex(T @NotNull [] elements, @NotNull T e) {
    for (int i=0; i<elements.length; i++) {
      T element = elements[i];
      if (comparator.compare(e, element) < 0) {
        return i;
      }
    }
    return elements.length;
  }
private int insertionIndex(T @NotNull [] elements, @NotNull T e)