/** * 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--)); } } } }