mckay.utilities.vectorsorter
Class SortableVector<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<E>
              extended by mckay.utilities.vectorsorter.SortableVector<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

public class SortableVector<E>
extends java.util.Vector<E>

A Vector that includes a generalized implementation of the Quicksort algorithm. A SortableVector will sort its own contents when its sort method is called.

An implementation of the QuicksortComparator interface is needed in order to determine on what basis the vector is to be sorted. This QuicksortComparator implementation is passed to the SortableVector during construction.

The StringSortableVector class in this package provides an example of how the this SortableVector class can be used in practice.

This approach to the Quicksort algorithm is derived from Bruce Eckel's implementation, which can be found at: http://www.codeguru.com/java/tij/tij0091.shtml

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SortableVector(QuicksortComparator comparator)
          Stores the given QuicksortComparator object that will compare the elements during ordering.
 
Method Summary
 void sort()
          Iniates sorting of this Vector using the Quicksort algorithm.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

SortableVector

public SortableVector(QuicksortComparator comparator)
Stores the given QuicksortComparator object that will compare the elements during ordering.

Parameters:
comparator - Will evaluate relative values of elements during sorting.
Method Detail

sort

public void sort()
Iniates sorting of this Vector using the Quicksort algorithm.