APTCONVERT 1.1

fr.pixware.util
Class QuickSort

java.lang.Object
  extended by fr.pixware.util.QuickSort

public class QuickSort
extends java.lang.Object

A quick sort function (static method). The objects to be compared (example: String) are not required to implement a specific interface (example: Comparable). Instead the following design was chosen: the quick sort function is passed a comparator (example: StringCompare), an object which implements inner interface QuickSort.Compare.


Nested Class Summary
static interface QuickSort.Compare
          Interface implemented by comparators, that is, objects able to compare two objects.
static class QuickSort.StringCompare
          The class of String comparators.
 
Field Summary
static QuickSort.StringCompare stringCompare
          An instance of StringCompare.
 
Constructor Summary
QuickSort()
           
 
Method Summary
static void main(java.lang.String[] args)
          Simple test.
static void sort(java.lang.Object[] values, int first, int last, QuickSort.Compare compare)
          Sorts a slice in an array of objects.
static void sort(java.lang.Object[] values, QuickSort.Compare compare)
          Sorts an array of objects.
static void sort(java.lang.String[] strings)
          Sorts an array of Strings lexicographically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringCompare

public static QuickSort.StringCompare stringCompare
An instance of StringCompare.

Constructor Detail

QuickSort

public QuickSort()
Method Detail

sort

public static void sort(java.lang.String[] strings)
Sorts an array of Strings lexicographically.

Parameters:
strings - the array of Strings to be sorted

sort

public static void sort(java.lang.Object[] values,
                        QuickSort.Compare compare)
Sorts an array of objects.

Parameters:
values - the array of Objects to be sorted
compare - the Object comparator

sort

public static void sort(java.lang.Object[] values,
                        int first,
                        int last,
                        QuickSort.Compare compare)
Sorts a slice in an array of objects.

Parameters:
values - the array of Objects to be sorted
first - position of first object of the slice
last - position of last object of the slice
compare - the Object comparator

main

public static void main(java.lang.String[] args)
Simple test.


APTCONVERT 1.1