EDU.bmrb.rtfgen
Class VectorSorter

java.lang.Object
  |
  +--EDU.bmrb.rtfgen.VectorSorter

public class VectorSorter
extends java.lang.Object

This class defines a bunch of static methods for efficiently sorting Vectors. It also defines two interfaces that provide two different ways of comparing objects to be sorted. Adapted by Joe Crumpton, October 2000 from "Java Examples in a Nutshell" Sorter class


Inner Class Summary
static interface VectorSorter.Comparer
          This interface defines the compare() method used to compare two objects.
 
Constructor Summary
VectorSorter()
           
 
Method Summary
static void sort(java.util.Vector a, int from, int to, boolean up, VectorSorter.Comparer c)
          Sort a portion of a vector, using the comparison defined by the Comparer object c.
static void sort(java.util.Vector a, java.util.Vector b, int from, int to, boolean up, VectorSorter.Comparer c)
          This is the main sort() routine.
static void sort(java.util.Vector a, VectorSorter.Comparer c)
          Sort a vector of arbitrary objects into ascending order, using the comparison defined by the Comparer object c
static void sort(java.util.Vector a, java.util.Vector b, VectorSorter.Comparer c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorSorter

public VectorSorter()
Method Detail

sort

public static void sort(java.util.Vector a,
                        int from,
                        int to,
                        boolean up,
                        VectorSorter.Comparer c)
Sort a portion of a vector, using the comparison defined by the Comparer object c. If up is true, sort into ascending order, otherwise sort into descending order.

sort

public static void sort(java.util.Vector a,
                        java.util.Vector b,
                        int from,
                        int to,
                        boolean up,
                        VectorSorter.Comparer c)
This is the main sort() routine. It performs a quicksort on the elements of vector a between the element from and the element to. The up argument specifies whether the elements should be sorted into ascending (true) or descending (false) order. The Comparer argument c is used to perform comparisons between elements of the vector. The elements of the vector b are reordered in exactly the same way as the elements of vector a are.

sort

public static void sort(java.util.Vector a,
                        java.util.Vector b,
                        VectorSorter.Comparer c)

sort

public static void sort(java.util.Vector a,
                        VectorSorter.Comparer c)
Sort a vector of arbitrary objects into ascending order, using the comparison defined by the Comparer object c