/** * 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); } } /**
/** * 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); } /**
/** * Sorts the specified range of the receiver into * ascending numerical order. The sorting algorithm is a tuned quicksort, * adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) * P. 1249-1265 (November 1993). This algorithm offers n*log(n) * performance on many data sets that cause other quicksorts to degrade to * quadratic performance. * * <p><b>You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set.</b> * It is generally better to call <tt>sort()</tt> or <tt>sortFromTo(...)</tt> instead, because those methods automatically choose the best sorting algorithm. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void quickSortFromTo(int from, int to) { int mySize = size(); checkRangeFromTo(from, to, mySize); char[] myElements = elements(); java.util.Arrays.sort(myElements, from, to+1); elements(myElements); setSizeRaw(mySize); } /**
/** * Sorts the specified range of the receiver into * ascending numerical order. The sorting algorithm is a tuned quicksort, * adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a * Sort Function", Software-Practice and Experience, Vol. 23(11) * P. 1249-1265 (November 1993). This algorithm offers n*log(n) * performance on many data sets that cause other quicksorts to degrade to * quadratic performance. * * <p><b>You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set.</b> * It is generally better to call <tt>sort()</tt> or <tt>sortFromTo(...)</tt> instead, because those methods automatically choose the best sorting algorithm. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void quickSortFromTo(int from, int to) { int mySize = size(); checkRangeFromTo(from, to, mySize); char[] myElements = elements(); java.util.Arrays.sort(myElements, from, to+1); elements(myElements); setSizeRaw(mySize); } /**
/** * Sorts the specified range of the receiver into ascending order. * * The sorting algorithm is a modified mergesort (in which the merge is * omitted if the highest element in the low sublist is less than the * lowest element in the high sublist). This algorithm offers guaranteed * n*log(n) performance, and can approach linear performance on nearly * sorted lists. * * <p><b>You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set.</b> * It is generally better to call <tt>sort()</tt> or <tt>sortFromTo(...)</tt> instead, because those methods automatically choose the best sorting algorithm. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void mergeSortFromTo(int from, int to) { int mySize = size(); checkRangeFromTo(from, to, mySize); char[] myElements = elements(); cern.colt.Sorting.mergeSort(myElements, from, to+1); elements(myElements); setSizeRaw(mySize); } /**
/** * Sorts the specified range of the receiver into ascending order. * * The sorting algorithm is a modified mergesort (in which the merge is * omitted if the highest element in the low sublist is less than the * lowest element in the high sublist). This algorithm offers guaranteed * n*log(n) performance, and can approach linear performance on nearly * sorted lists. * * <p><b>You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set.</b> * It is generally better to call <tt>sort()</tt> or <tt>sortFromTo(...)</tt> instead, because those methods automatically choose the best sorting algorithm. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void mergeSortFromTo(int from, int to) { int mySize = size(); checkRangeFromTo(from, to, mySize); char[] myElements = elements(); cern.colt.Sorting.mergeSort(myElements, from, to+1); elements(myElements); setSizeRaw(mySize); } /**
cern.colt.Sorting.quickSort(myElements, from, to+1,c); elements(myElements); setSizeRaw(mySize);
cern.colt.Sorting.mergeSort(myElements, from, to+1, c); elements(myElements); setSizeRaw(mySize);
cern.colt.Sorting.quickSort(myElements, from, to+1,c); elements(myElements); setSizeRaw(mySize);
cern.colt.Sorting.mergeSort(myElements, from, to+1, c); elements(myElements); setSizeRaw(mySize);