/** * Inserts the part of the specified list between <code>otherFrom</code> (inclusive) and <code>otherTo</code> (inclusive) 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 first element from the specified list (must be in [0,size]).. * @param other list of which a part is to be inserted into the receiver. * @param from the index of the first element to be inserted (inclusive). * @param to the index of the last element to be inserted (inclusive). * @exception IndexOutOfBoundsException index is out of range (<tt>other.size()>0 && (from<0 || from>to || to>=other.size())</tt>). * @exception IndexOutOfBoundsException index is out of range (<tt>index < 0 || index > size()</tt>). */ public void beforeInsertAllOfFromTo(int index, AbstractIntList other, int from, int to) { int length=to-from+1; this.beforeInsertDummies(index, length); this.replaceFromToWithFrom(index, index+length-1, other, from); } /**
replaceFromToWithFrom(from,from+length-1,other,otherFrom);
/** * Inserts the part of the specified list between <code>otherFrom</code> (inclusive) and <code>otherTo</code> (inclusive) 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 first element from the specified list (must be in [0,size]).. * @param other list of which a part is to be inserted into the receiver. * @param from the index of the first element to be inserted (inclusive). * @param to the index of the last element to be inserted (inclusive). * @exception IndexOutOfBoundsException index is out of range (<tt>other.size()>0 && (from<0 || from>to || to>=other.size())</tt>). * @exception IndexOutOfBoundsException index is out of range (<tt>index < 0 || index > size()</tt>). */ public void beforeInsertAllOfFromTo(int index, AbstractIntList other, int from, int to) { int length=to-from+1; this.beforeInsertDummies(index, length); this.replaceFromToWithFrom(index, index+length-1, other, from); } /**
replaceFromToWithFrom(from,from+length-1,other,otherFrom);
/** * Inserts the part of the specified list between <code>otherFrom</code> * (inclusive) and <code>otherTo</code> (inclusive) 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 first element from the specified * list (must be in [0,size]).. * @param other * list of which a part is to be inserted into the receiver. * @param from * the index of the first element to be inserted (inclusive). * @param to * the index of the last element to be inserted (inclusive). * @exception IndexOutOfBoundsException * index is out of range ( * <tt>other.size()>0 && (from<0 || from>to || to>=other.size())</tt> * ). * @exception IndexOutOfBoundsException * index is out of range ( * <tt>index < 0 || index > size()</tt>). */ public void beforeInsertAllOfFromTo(int index, AbstractIntList other, int from, int to) { int length = to - from + 1; this.beforeInsertDummies(index, length); this.replaceFromToWithFrom(index, index + length - 1, other, from); }
replaceFromToWithFrom(from, from + length - 1, other, otherFrom);
/** * Inserts <tt>length</tt> dummy elements before the specified position into the receiver. * Shifts the element currently at that position (if any) and * any subsequent elements to the right. * <b>This method must set the new size to be <tt>size()+length</tt>. * * @param index index before which to insert dummy elements (must be in [0,size]).. * @param length number of dummy elements to be inserted. * @throws IndexOutOfBoundsException if <tt>index < 0 || index > size()</tt>. */ 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); setSizeRaw(size + length); replaceFromToWithFrom(index+length,size-1,this,index); } } /**
/** * Inserts <tt>length</tt> dummy elements before the specified position into the receiver. * Shifts the element currently at that position (if any) and * any subsequent elements to the right. * <b>This method must set the new size to be <tt>size()+length</tt>. * * @param index index before which to insert dummy elements (must be in [0,size]).. * @param length number of dummy elements to be inserted. * @throws IndexOutOfBoundsException if <tt>index < 0 || index > size()</tt>. */ 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); setSizeRaw(size + length); replaceFromToWithFrom(index+length,size-1,this,index); } } /**
/** * Inserts <tt>length</tt> dummy elements before the specified position into * the receiver. Shifts the element currently at that position (if any) and * any subsequent elements to the right. <b>This method must set the new * size to be <tt>size()+length</tt></b>. * * @param index * index before which to insert dummy elements (must be in * [0,size]).. * @param length * number of dummy elements to be inserted. * @throws IndexOutOfBoundsException * if <tt>index < 0 || index > size()</tt>. */ 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); setSizeRaw(size + length); replaceFromToWithFrom(index + length, size - 1, this, index); } }
/** * Removes from the receiver all elements whose index is between * <code>from</code>, inclusive and <code>to</code>, inclusive. Shifts any succeeding * elements to the left (reduces their index). * This call shortens the list by <tt>(to - from + 1)</tt> elements. * * @param from index of first element to be removed. * @param to index of last element to be removed. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void removeFromTo(int from, int to) { checkRangeFromTo(from, to, size); int numMoved = size - to - 1; if (numMoved > 0) { replaceFromToWithFrom(from, from-1+numMoved, this, to+1); //fillFromToWith(from+numMoved, size-1, 0.0f); //delta } int width = to-from+1; if (width>0) setSizeRaw(size-width); } /**
/** * Removes from the receiver all elements whose index is between * <code>from</code>, inclusive and <code>to</code>, inclusive. Shifts any succeeding * elements to the left (reduces their index). * This call shortens the list by <tt>(to - from + 1)</tt> elements. * * @param from index of first element to be removed. * @param to index of last element to be removed. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void removeFromTo(int from, int to) { checkRangeFromTo(from, to, size); int numMoved = size - to - 1; if (numMoved > 0) { replaceFromToWithFrom(from, from-1+numMoved, this, to+1); //fillFromToWith(from+numMoved, size-1, 0.0f); //delta } int width = to-from+1; if (width>0) setSizeRaw(size-width); } /**
/** * Removes from the receiver all elements whose index is between * <code>from</code>, inclusive and <code>to</code>, inclusive. Shifts any * succeeding elements to the left (reduces their index). This call shortens * the list by <tt>(to - from + 1)</tt> elements. * * @param from * index of first element to be removed. * @param to * index of last element to be removed. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void removeFromTo(int from, int to) { checkRangeFromTo(from, to, size); int numMoved = size - to - 1; if (numMoved > 0) { replaceFromToWithFrom(from, from - 1 + numMoved, this, to + 1); // fillFromToWith(from+numMoved, size-1, 0.0f); //delta } int width = to - from + 1; if (width > 0) setSizeRaw(size - width); }
/** * 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, AbstractIntList other, int otherFrom) { // overridden for performance only. if (! (other instanceof IntArrayList)) { // slower super.replaceFromToWithFrom(from,to,other,otherFrom); return; } int length=to-from+1; if (length>0) { checkRangeFromTo(from, to, size()); checkRangeFromTo(otherFrom,otherFrom+length-1,other.size()); System.arraycopy(((IntArrayList) other).elements, otherFrom, elements, from, length); } } /**
/** * 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, AbstractIntList other, int otherFrom) { // overridden for performance only. if (! (other instanceof IntArrayList)) { // slower super.replaceFromToWithFrom(from,to,other,otherFrom); return; } int length=to-from+1; if (length>0) { checkRangeFromTo(from, to, size()); checkRangeFromTo(otherFrom,otherFrom+length-1,other.size()); System.arraycopy(((IntArrayList) other).elements, otherFrom, elements, from, length); } } /**
super.replaceFromToWithFrom(from, to, other, otherFrom); return;