@Override
  public E set(int index, E element) {
    int size = mySize;
    checkOutOfBounds(index, size);
    E oldValue;
    if (size == 1) {
      oldValue = asElement();
      myElem = element;
    }
    else {
      Object[] array = asArray();
      oldValue = getFromArray(array, index);
      array[index] = element;
    }
    return oldValue;
  }
@Override
  public E set(int index, E element)