AbstractList
cern.colt.list

Class AbstractList

    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      voidaddAllOf(Collection collection)
      Appends all of the elements of the specified Collection to the receiver.
      voidbeforeInsertAllOf(int index, Collection collection)
      Inserts all elements of the specified collection before the specified position into the receiver.
      voidclear()
      Removes all elements from the receiver.
      voidmergeSort()
      Sorts the receiver into ascending order.
      abstract voidmergeSortFromTo(int from, int to)
      Sorts the receiver into ascending order.
      voidquickSort()
      Sorts the receiver into ascending order.
      abstract voidquickSortFromTo(int from, int to)
      Sorts the specified range of the receiver into ascending order.
      voidremove(int index)
      Removes the element at the specified position from the receiver.
      abstract voidremoveFromTo(int fromIndex, int toIndex)
      Removes from the receiver all elements whose index is between from, inclusive and to, inclusive.
      abstract voidreplaceFromWith(int from, Collection other)
      Replaces the part of the receiver starting at from (inclusive) with all the elements of the specified collection.
      abstract voidreverse()
      Reverses the elements of the receiver.
      voidsetSize(int newSize)
      Sets the size of the receiver.
      voidshuffle()
      Randomly permutes the receiver.
      abstract voidshuffleFromTo(int from, int to)
      Randomly permutes the receiver between from (inclusive) and to (inclusive).
      voidsort()
      Sorts the receiver into ascending order.
      voidsortFromTo(int from, int to)
      Sorts the specified range of the receiver into ascending order.
      voidtrimToSize()
      Trims the capacity of the receiver to be the receiver's current size.
    • Method Detail

      • addAllOf

        public void addAllOf(Collection collection)
        Appends all of the elements of the specified Collection to the receiver.
        Throws:
        ClassCastException - if an element in the collection is not of the same parameter type of the receiver.
      • beforeInsertAllOf

        public void beforeInsertAllOf(int index,                     Collection collection)
        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 indexes).
        Parameters:
        index - index before which to insert first element from the specified collection.
        collection - the collection to be inserted
        Throws:
        ClassCastException - if an element in the collection is not of the same parameter type of the receiver.
        IndexOutOfBoundsException - if index < 0 || index > size().
      • clear

        public void clear()
        Removes all elements from the receiver. The receiver will be empty after this call returns, but keep its current capacity.
        Specified by:
        clear in class AbstractCollection
      • mergeSort

        public final void mergeSort()
        Sorts the receiver into ascending order. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

        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.

        You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.

      • mergeSortFromTo

        public abstract void mergeSortFromTo(int from,                   int to)
        Sorts the receiver into ascending order. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

        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.

        You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.

        Parameters:
        from - the index of the first element (inclusive) to be sorted.
        to - the index of the last element (inclusive) to be sorted.
        Throws:
        IndexOutOfBoundsException - if (from<0 || from>to || to>=size()) && to!=from-1 .
      • quickSort

        public final void quickSort()
        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.

        You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.

      • quickSortFromTo

        public abstract void quickSortFromTo(int from,                   int to)
        Sorts the specified range of 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.

        You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set. It is generally better to call sort() or sortFromTo(...) instead, because those methods automatically choose the best sorting algorithm.

        Parameters:
        from - the index of the first element (inclusive) to be sorted.
        to - the index of the last element (inclusive) to be sorted.
        Throws:
        IndexOutOfBoundsException - if (from<0 || from>to || to>=size()) && to!=from-1 .
      • remove

        public void remove(int index)
        Removes the element at the specified position from the receiver. Shifts any subsequent elements to the left.
        Parameters:
        index - the index of the element to removed.
        Throws:
        IndexOutOfBoundsException - if index < 0 || index >= size().
      • removeFromTo

        public abstract void removeFromTo(int fromIndex,                int toIndex)
        Removes from the receiver all elements whose index is between from, inclusive and to, inclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by (to - from + 1) elements.
        Parameters:
        fromIndex - index of first element to be removed.
        toIndex - index of last element to be removed.
        Throws:
        IndexOutOfBoundsException - if (from<0 || from>to || to>=size()) && to!=from-1 .
      • replaceFromWith

        public abstract void replaceFromWith(int from,                   Collection other)
        Replaces the part of the receiver starting at from (inclusive) with all the elements of the specified collection. Does not alter the size of the receiver. Replaces exactly Math.max(0,Math.min(size()-from, other.size())) elements.
        Parameters:
        from - the index at which to copy the first element from the specified collection.
        other - Collection to replace part of the receiver
        Throws:
        IndexOutOfBoundsException - if index < 0 || index >= size().
      • reverse

        public abstract void reverse()
        Reverses the elements of the receiver. Last becomes first, second last becomes second first, and so on.
      • setSize

        public void setSize(int newSize)
        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 trimToSize to release superfluos internal memory.
        Parameters:
        newSize - the new size of the receiver.
        Throws:
        IndexOutOfBoundsException - if newSize < 0.
      • shuffle

        public final void shuffle()
        Randomly permutes the receiver. After invocation, all elements will be at random positions.
      • shuffleFromTo

        public abstract void shuffleFromTo(int from,                 int to)
        Randomly permutes the receiver between from (inclusive) and to (inclusive).
        Parameters:
        from - the start position (inclusive)
        to - the end position (inclusive)
        Throws:
        IndexOutOfBoundsException - if (from<0 || from>to || to>=size()) && to!=from-1 .
      • sort

        public final void sort()
        Sorts the receiver into ascending order. The sorting algorithm is dynamically chosen according to the characteristics of the data set. This implementation simply calls sortFromTo(...). Override sortFromTo(...) if you can determine which sort is most appropriate for the given data set.
      • sortFromTo

        public void sortFromTo(int from,              int to)
        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.
        Parameters:
        from - the index of the first element (inclusive) to be sorted.
        to - the index of the last element (inclusive) to be sorted.
        Throws:
        IndexOutOfBoundsException - if (from<0 || from>to || to>=size()) && to!=from-1 .
      • trimToSize

        public void trimToSize()
        Trims the capacity of the receiver to be the receiver's current size. Releases any superfluos internal memory. An application can use this operation to minimize the storage of the receiver.

        This default implementation does nothing. Override this method in space efficient implementations.

SCaVis 2.1 © jWork.ORG