/**
   * Reverses the elements of the receiver. Last becomes first, second last becomes second first,
   * and so on.
   */
  @Override
  public void reverse() {
    long[] tmp;
    int limit = size() / 2;
    int j = size() - 1;

    for (int i = 0; i < limit; ) { // swap
      tmp = getQuick(i);
      setQuick(i++, getQuick(j));
      setQuick(j--, tmp);
    }
  }
  /**
   * Replaces a number of elements in the receiver with the same number of elements of another list.
   * Replaces elements in the receiver, between <code>from</code> (inclusive) and <code>to</code>
   * (inclusive), with elements of <code>other</code>, starting from <code>otherFrom</code>
   * (inclusive).
   *
   * @param from the position of the first element to be replaced in the receiver
   * @param to the position of the last element to be replaced in the receiver
   * @param other list holding elements to be copied into the receiver.
   * @param otherFrom position of first element within other list to be copied.
   */
  public void replaceFromToWithFrom(int from, int to, AbstractUuidList other, int otherFrom) {
    int length = to - from + 1;
    if (length > 0) {
      checkRangeFromTo(from, to, size());
      checkRangeFromTo(otherFrom, otherFrom + length - 1, other.size());

      // unambiguous copy (it may hold other==this)
      if (from <= otherFrom) {
        for (; --length >= 0; ) {
          setQuick(from++, other.getQuick(otherFrom++));
        }
      } else {
        int otherTo = otherFrom + length - 1;
        for (; --length >= 0; ) {
          setQuick(to--, other.getQuick(otherTo--));
        }
      }
    }
  }
  /**
   * Removes from the receiver all elements that are contained in the specified list. Tests for
   * identity.
   *
   * @param other the other list.
   * @return <code>true</code> if the receiver changed as a result of the call.
   */
  public boolean removeAll(AbstractUuidList other) {
    if (other.size() == 0) {
      return false; // nothing to do
    }
    int limit = other.size() - 1;
    int j = 0;

    for (int i = 0; i < size; i++) {
      if (other.indexOfFromTo(getQuick(i), 0, limit) < 0) {
        setQuick(j++, getQuick(i));
      }
    }

    boolean modified = (j != size);
    setSize(j);
    return modified;
  }
  /**
   * Retains (keeps) only the elements in the receiver that are contained in the specified other
   * list. In other words, removes from the receiver all of its elements that are not contained in
   * the specified other list.
   *
   * @param other the other list to test against.
   * @return <code>true</code> if the receiver changed as a result of the call.
   */
  public boolean retainAll(AbstractUuidList other) {
    if (other.size() == 0) {
      if (size == 0) {
        return false;
      }
      setSize(0);
      return true;
    }

    int limit = other.size() - 1;
    int j = 0;
    for (int i = 0; i < size; i++) {
      if (other.indexOfFromTo(getQuick(i), 0, limit) >= 0) {
        setQuick(j++, getQuick(i));
      }
    }

    boolean modified = (j != size);
    setSize(j);
    return modified;
  }
 /**
  * Replaces the element at the specified position in the receiver with the specified element.
  *
  * @param index index of element to replace.
  * @param element element to be stored at the specified position.
  * @throws IndexOutOfBoundsException if <tt>index &lt; 0 || index &gt;= size()</tt>.
  */
 public void set(int index, long[] element) {
   if (index >= size || index < 0) {
     throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
   }
   setQuick(index, element);
 }
 /**
  * Sets the specified range of elements in the specified array to the specified value.
  *
  * @param from the index of the first element (inclusive) to be filled with the specified value.
  * @param to the index of the last element (inclusive) to be filled with the specified value.
  * @param val the value to be stored in the specified elements of the receiver.
  */
 public void fillFromToWith(int from, int to, long[] val) {
   checkRangeFromTo(from, to, this.size);
   for (int i = from; i <= to; ) {
     setQuick(i++, val);
   }
 }