/**
  * Inserts the specified element before the specified position into the receiver. Shifts the
  * element currently at that position (if any) and any subsequent elements to the right.
  *
  * @param index index before which the specified element is to be inserted (must be in [0,size]).
  * @param element element to be inserted.
  * @exception IndexOutOfBoundsException index is out of range (<tt>index &lt; 0 || index &gt;
  *     size()</tt>).
  */
 public void beforeInsert(int index, Object element) {
   // overridden for performance only.
   if (index > size || index < 0)
     throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
   ensureCapacity(size + 1);
   System.arraycopy(elements, index, elements, index + 1, size - index);
   elements[index] = element;
   size++;
 }
 /**
  * Inserts length dummies before the specified position into the receiver. Shifts the element
  * currently at that position (if any) and any subsequent elements to the right.
  *
  * @param index index before which to insert dummies (must be in [0,size])..
  * @param length number of dummies to be inserted.
  */
 protected void beforeInsertDummies(int index, int length) {
   if (index > size || index < 0)
     throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
   if (length > 0) {
     ensureCapacity(size + length);
     System.arraycopy(elements, index, elements, index + length, size - index);
     size += length;
   }
 }
 /**
  * Appends the specified element to the end of this list.
  *
  * @param element element to be appended to this list.
  */
 public void add(Object element) {
   if (size == elements.length) ensureCapacity(size + 1);
   elements[size++] = element;
 }