comirva.util
Class VectorSort

java.lang.Object
  extended by comirva.util.VectorSort

public class VectorSort
extends Object

This class implements special algorithms needed for sorting Float Vectors and updating their accompanying meta-data vectors.


Field Summary
static int ASC_ORDER
           
static int DEC_ORDER
           
 
Constructor Summary
VectorSort()
           
 
Method Summary
(package private) static void doQuickSort(int leftBorder, int rightBorder, double[] sortArray, String[] metaDataArray)
          Uses Quick-Sort to sort the array sortArray and adapt the array metaDataArray accordingly.
static void doQuickSortFloat(int leftBorder, int rightBorder, float[] sortArray, String[] metaDataArray, int order)
          Uses Quick-Sort to sort the array sortArray and adapt the array metaDataArray accordingly.
static void sortWithMetaData(Vector sort, Vector metaData)
          Sorts the Vector sort in decreasing order and also updates the Vector metaData.
static void sortWithMetaDataFloat(Vector<Float> sort, Vector<String> metaData)
          Sorts the Vector sort in decreasing order and also updates the Vector metaData.
static void sortWithMetaDataFloat(Vector<Float> sort, Vector<String> metaData, int order)
          Sorts the Vector sort in ascending or decreasing order and also updates the Vector metaData.
static void sortWithMetaDataInt(Vector<Integer> sort, Vector<String> metaData)
          Sorts the Vector sort in decreasing order and also updates the Vector metaData.
static void sortWithMetaDataInt(Vector<Integer> sort, Vector<String> metaData, int order)
          Sorts the Vector sort in ascending or decreasing order and also updates the Vector metaData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASC_ORDER

public static final int ASC_ORDER
See Also:
Constant Field Values

DEC_ORDER

public static final int DEC_ORDER
See Also:
Constant Field Values
Constructor Detail

VectorSort

public VectorSort()
Method Detail

sortWithMetaDataFloat

public static void sortWithMetaDataFloat(Vector<Float> sort,
                                         Vector<String> metaData)
Sorts the Vector sort in decreasing order and also updates the Vector metaData. Each element in Vector sort is considered to have a meta-data element in Vector metaData at the same position. For example, metaData.elementAt[i] is considered to be a String describing the value sort.elementAt[i]. After the sort, the Vector sort is sorted and the Vector metaData is adapted according to the new positions of the values in sort.

Parameters:
sort - a Vector containing Floats that represent a distance vector
metaData - a Vector containing Strings that represent the meta-data to be adapted
order - sort in ascending or decreasing order (ASC_ORDER/DESC_ORDER)

sortWithMetaDataFloat

public static void sortWithMetaDataFloat(Vector<Float> sort,
                                         Vector<String> metaData,
                                         int order)
Sorts the Vector sort in ascending or decreasing order and also updates the Vector metaData. Each element in Vector sort is considered to have a meta-data element in Vector metaData at the same position. For example, metaData.elementAt[i] is considered to be a String describing the value sort.elementAt[i]. After the sort, the Vector sort is sorted and the Vector metaData is adapted according to the new positions of the values in sort.

Parameters:
sort - a Vector containing Floats that represent a distance vector
metaData - a Vector containing Strings that represent the meta-data to be adapted
order - sort in ascending or decreasing order (ASC_ORDER/DESC_ORDER)

doQuickSortFloat

public static void doQuickSortFloat(int leftBorder,
                                    int rightBorder,
                                    float[] sortArray,
                                    String[] metaDataArray,
                                    int order)
Uses Quick-Sort to sort the array sortArray and adapt the array metaDataArray accordingly. Sorting is performed in decreasing order.

Parameters:
leftBorder - the left border for the Quick-Sort algorithm
rightBorder - the right border for the Quick-Sort algorithm
sortArray - a float[] representing the values to be sorted
metaDataArray - a String[] representing the meta-data to be updated according to new order after the sort
order - sort in ascending or decreasing order (ASC_ORDER/DESC_ORDER)

sortWithMetaDataInt

public static void sortWithMetaDataInt(Vector<Integer> sort,
                                       Vector<String> metaData)
Sorts the Vector sort in decreasing order and also updates the Vector metaData. Each element in Vector sort is considered to have a meta-data element in Vector metaData at the same position. For example, metaData.elementAt[i] is considered to be a String describing the value sort.elementAt[i]. After the sort, the Vector sort is sorted and the Vector metaData is adapted according to the new positions of the values in sort.

Parameters:
sort - a Vector containing Floats that represent a distance vector
metaData - a Vector containing Strings that represent the meta-data to be adapted
order - sort in ascending or decreasing order (ASC_ORDER/DESC_ORDER)

sortWithMetaDataInt

public static void sortWithMetaDataInt(Vector<Integer> sort,
                                       Vector<String> metaData,
                                       int order)
Sorts the Vector sort in ascending or decreasing order and also updates the Vector metaData. Each element in Vector sort is considered to have a meta-data element in Vector metaData at the same position. For example, metaData.elementAt[i] is considered to be a String describing the value sort.elementAt[i]. After the sort, the Vector sort is sorted and the Vector metaData is adapted according to the new positions of the values in sort.

Parameters:
sort - a Vector containing Integers that represent a distance vector
metaData - a Vector containing Strings that represent the meta-data to be adapted
order - sort in ascending or decreasing order (ASC_ORDER/DESC_ORDER)

sortWithMetaData

public static void sortWithMetaData(Vector sort,
                                    Vector metaData)
Sorts the Vector sort in decreasing order and also updates the Vector metaData. Each element in Vector sort is considered to have a meta-data element in Vector metaData at the same position. For example, metaData.elementAt[i] is considered to be a String describing the value sort.elementAt[i]. After the sort, the Vector sort is sorted and the Vector metaData is adapted according to the new positions of the values in sort.

Parameters:
sort - a Vector containing Doubles that represent a distance vector
metaData - a Vector containing Strings that represent the meta-data to be adapted

doQuickSort

static void doQuickSort(int leftBorder,
                        int rightBorder,
                        double[] sortArray,
                        String[] metaDataArray)
Uses Quick-Sort to sort the array sortArray and adapt the array metaDataArray accordingly. Sorting is performed in decreasing order.

Parameters:
leftBorder - the left border for the Quick-Sort algorithm
rightBorder - the right border for the Quick-Sort algorithm
sortArray - a double[] representing the values to be sorted
metaDataArray - a String[] representing the meta-data to be updated according to new order after the sort