com.ltu.smd116.misc
Class SortedVector

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--com.ltu.smd116.misc.SortedVector
Direct Known Subclasses:
SampleContainer

public class SortedVector
extends Vector

This class serves the purpose of List as defined in Java 1.2 AND
also implements the static function for sorting this type of set with
the use of the Comparator interface (i.e. the functionality provided
by the Collections-class).
Creation date: (2/27/2001 4:34:04 PM)

Author:
:

Field Summary
 (package private) intiSortColumn
           

Fields inherited from class java.util.Vector
elementData, elementCount, capacityIncrement

Fields inherited from class java.util.AbstractList
modCount

Constructor Summary
SortedVector()
          Constructor

Method Summary
 voidaddSortedVectorElements(SortedVector v)
          Add all elements (by references) to this SortedVector.
 private voidquicksort(int left, int right)
          Sorts this vector using an ExtendedComparator.
 voidsetSortColumn(int i)
           
 voidsort()
          Sorts the elements in the vector.
 private voidswap(int i, int j)
          Switch places between objects at 'i' and 'j'.

Methods inherited from class java.util.Vector
copyInto, trimToSize, ensureCapacity, setSize, capacity, size, isEmpty, elements, contains, indexOf, indexOf, lastIndexOf, lastIndexOf, elementAt, firstElement, lastElement, setElementAt, removeElementAt, insertElementAt, addElement, removeElement, removeAllElements, clone, toArray, toArray, get, set, add, remove, add, remove, clear, containsAll, addAll, removeAll, retainAll, addAll, equals, hashCode, toString, subList, removeRange

Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator

Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait, finalize

Field Detail

iSortColumn

int iSortColumn
Constructor Detail

SortedVector

public SortedVector()
Constructor
Method Detail

addSortedVectorElements

public void addSortedVectorElements(SortedVector v)
Add all elements (by references) to this SortedVector.
Parameters:
v - the vector to be copied.

quicksort

private void quicksort(int left, int right)
Sorts this vector using an ExtendedComparator.
Implementation of the QuickSort algorithm.
Parameters:
left - (algorithm specific)
right - (algorithm specific)

setSortColumn

public void setSortColumn(int i)

sort

public void sort()
Sorts the elements in the vector. If the vector is empty (size < 1) the
method does nothing. Sorting is made using a primary and a secondary Comparator.
This way we can get a unique sort order by sorting on a primary key or id using
the secondary Comparator. See the wideyes.admin.container.ExtendedComparator for more info.
Parameters:
comp - the primary comparator.
subComp - the secondary comparator.
See Also:
wideyes.admin.container.ExtendedComparator

swap

private void swap(int i, int j)
Switch places between objects at 'i' and 'j'.
Parameters:
i - the position that the object at position j will be placed in.
j - the position that the object at position i will be placed in.