/** * Sets the size of the receiver. * If the new size is greater than the current size, new null or zero items are added to the end of the receiver. * If the new size is less than the current size, all components at index newSize and greater are discarded. * This method does not release any superfluos internal memory. Use method <tt>trimToSize</tt> to release superfluos internal memory. * @param newSize the new size of the receiver. * @throws IndexOutOfBoundsException if <tt>newSize < 0</tt>. */ public void setSize(int newSize) { if (newSize<0) throw new IndexOutOfBoundsException("newSize:"+newSize); int currentSize = size(); if (newSize!=currentSize) { if (newSize>currentSize) beforeInsertDummies(currentSize,newSize-currentSize); else if (newSize<currentSize) removeFromTo(newSize, currentSize-1); } } /**
/** * Appends all of the elements of the specified Collection to the * receiver. * * @exception ClassCastException if an element in the collection is not * of the same parameter type of the receiver. */ public void addAllOf(java.util.Collection collection) { this.beforeInsertAllOf(size(), collection); } /** Inserts all elements of the specified collection before the specified position into the receiver.
/** * Sorts the receiver into ascending order. * This sort is guaranteed to be <i>stable</i>: equal elements will * not be reordered as a result of the sort.<p> * * 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. */ public final void mergeSort() { mergeSortFromTo(0, size()-1); } /**
/** * Sorts the receiver into ascending order. * * The sorting algorithm is dynamically chosen according to the characteristics of the data set. * * This implementation simply calls <tt>sortFromTo(...)</tt>. * Override <tt>sortFromTo(...)</tt> if you can determine which sort is most appropriate for the given data set. */ public final void sort() { sortFromTo(0, size()-1); } /**
/** * Randomly permutes the receiver. After invocation, all elements will be at random positions. */ public final void shuffle() { shuffleFromTo(0, size()-1); } /**
/** * Removes all elements from the receiver. The receiver will * be empty after this call returns, but keep its current capacity. */ public void clear() { removeFromTo(0,size()-1); } /**
/** * Sorts the receiver into * ascending 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. */ public final void quickSort() { quickSortFromTo(0, size()-1); } /**
public void setCurCoordIndex (int i) { curCoordIndex = i; curCoordInCycle = (i + startPointInCycle) % curCycle.size(); }
/** Inserts all elements of the specified collection before the specified position into the receiver. * Shifts the element * currently at that position (if any) and any subsequent elements to * the right (increases their indices). * * @param index index before which to insert first element from the specified collection. * @param collection the collection to be inserted * @exception ClassCastException if an element in the collection is not * of the same parameter type of the receiver. * @throws IndexOutOfBoundsException if <tt>index < 0 || index > size()</tt>. */ public void beforeInsertAllOf(int index, java.util.Collection collection) { this.beforeInsertDummies(index, collection.size()); this.replaceFromWith(index, collection); } /**
/** * Removes the element at the specified position from the receiver. * Shifts any subsequent elements to the left. * * @param index the index of the element to removed. * @throws IndexOutOfBoundsException if <tt>index < 0 || index >= size()</tt>. */ public void remove(int index) { removeFromTo(index, index); } /**
/** * Returns a copy of the receiver such that the copy and the receiver <i>share</i> the same elements, but do not share the same array to index them; * So modifying an object in the copy modifies the object in the receiver and vice versa; * However, structurally modifying the copy (for example changing its size, setting other objects at indexes, etc.) does not affect the receiver and vice versa. * * @return a copy of the receiver. */ public Object clone() { ObjectArrayList v = (ObjectArrayList)super.clone(); v.elements = (Object[]) elements.clone(); return v; } /**
/** * Sorts the specified range of the receiver into ascending order. * * The sorting algorithm is dynamically chosen according to the characteristics of the data set. * This default implementation simply calls quickSort. * Override this method if you can determine which sort is most appropriate for the given data set. * * @param from the index of the first element (inclusive) to be sorted. * @param to the index of the last element (inclusive) to be sorted. * @throws IndexOutOfBoundsException if <tt>(from<0 || from>to || to>=size()) && to!=from-1</tt>. */ public void sortFromTo(int from, int to) { quickSortFromTo(from, to); } /**
/** * Sorts the receiver into ascending order. * * The sorting algorithm is dynamically chosen according to the characteristics of the data set. * * This implementation simply calls <tt>sortFromTo(...)</tt>. * Override <tt>sortFromTo(...)</tt> if you can determine which sort is most appropriate for the given data set. */ public final void sort() { sortFromTo(0, size()-1); } /**
/** * Randomly permutes the receiver. After invocation, all elements will be at * random positions. */ public final void shuffle() { shuffleFromTo(0, size() - 1); }
/** * Removes all elements from the receiver. The receiver will be empty after * this call returns, but keep its current capacity. */ public void clear() { removeFromTo(0, size() - 1); }
/** * Sorts the receiver into * ascending 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. */ public final void quickSort() { quickSortFromTo(0, size()-1); } /**
/** * Adds the cycle <TT>c</TT> to the list of all cycles. * This method is used by subclass constructors to fill up the list of cycles. * */ protected void addCycle (AbstractList c) { // Adds the cycle \texttt{c} to the list of all cycles. // Used by subclass constructors to fill up the list of cycles. cycles.add (c); numCycles++; numPoints += c.size(); }
/** Inserts all elements of the specified collection before the specified position into the receiver. * Shifts the element * currently at that position (if any) and any subsequent elements to * the right (increases their indices). * * @param index index before which to insert first element from the specified collection. * @param collection the collection to be inserted * @exception ClassCastException if an element in the collection is not * of the same parameter type of the receiver. * @throws IndexOutOfBoundsException if <tt>index < 0 || index > size()</tt>. */ public void beforeInsertAllOf(int index, java.util.Collection collection) { this.beforeInsertDummies(index, collection.size()); this.replaceFromWith(index, collection); } /**
/** * Removes the element at the specified position from the receiver. * Shifts any subsequent elements to the left. * * @param index the index of the element to removed. * @throws IndexOutOfBoundsException if <tt>index < 0 || index >= size()</tt>. */ public void remove(int index) { removeFromTo(index, index); } /**
/** * Returns a copy of the receiver such that the copy and the receiver <i>share</i> the same elements, but do not share the same array to index them; * So modifying an object in the copy modifies the object in the receiver and vice versa; * However, structurally modifying the copy (for example changing its size, setting other objects at indexes, etc.) does not affect the receiver and vice versa. * * @return a copy of the receiver. */ public Object clone() { ObjectArrayList v = (ObjectArrayList)super.clone(); v.elements = (Object[]) elements.clone(); return v; } /**