int findIndex(T val)
  {
    int lb = 0;
    int ub = this.core.size();

    // Invariant:
    //   +-------+------+-------+
    //   | < val |  ?   | > val |
    //   +-------+------+-------+
    //   0       lb     ub      length
    while (lb < ub)
      {
        // Find the midpoint in a relatively safe way (assuming
        // the lb and ub are positive integers).
        int mid = lb + (ub - lb) / 2;
        T midval = this.core.get(mid);
        if (val.compareTo(midval) == 0)
          return mid;
        else if (val.compareTo(midval) > 0)
          lb = mid + 1;
        else
          ub = mid;
      } // while

    // If we've reached this point we know that
    //   +-------+-------+
    //   | < val | > val |
    //   +-------+-------+
    //   0       lb,ub   length
    // We therefore need to add an element at lb.
    return lb;
  } // findIndex(T)