code: public double set(long idx, double value) {
          int i = SafeCast.safeLongToInt(idx);
          idxAfterLast = Math.max(idxAfterLast, i + 1);
          ensureCapacity(idxAfterLast);
          double old = elements[i];
          elements[i] = value;
          return old;
      }
docs: Sets the i'th entry of the vector to the given value.
  @param i The index to set.
  @param value The value to set.