/**
  * Returns a list which is a concatenation of <code>times</code> times the receiver.
  *
  * @param times the number of times the receiver shall be copied.
  */
 public AbstractUuidList times(int times) {
   AbstractUuidList newList = new UuidArrayList(times * size());
   for (int i = times; --i >= 0; ) {
     newList.addAllOfFromTo(this, 0, size() - 1);
   }
   return newList;
 }
  /**
   * 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;
  }
  /**
   * 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--));
        }
      }
    }
  }
  /**
   * 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;
  }