jpos.util
Class Sorter

java.lang.Object
  |
  +--jpos.util.Sorter

public final class Sorter
extends java.lang.Object

This is utility class to sort Comparable elements in Vector objects

Version:
1.1.x (JDK 1.1.x)
Author:
E. Michael Maximilien (maxim@us.ibm.com)

Method Summary
static java.util.Vector insertionSort(java.util.Vector comparables)
           
static Comparable max(java.util.Vector comparables)
           
static java.util.Vector mergeSort(java.util.Vector comparables)
           
static Comparable min(java.util.Vector comparables)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

min

public static Comparable min(java.util.Vector comparables)
Returns:
the smallest Comparable element in this Vector NOTE:implements a simple one pass algorithm in O(n) time

max

public static Comparable max(java.util.Vector comparables)
Returns:
the greatest Comparable element in this Vector NOTE:implements a simple one pass algorithm in O(n) time

insertionSort

public static java.util.Vector insertionSort(java.util.Vector comparables)
Parameters:
elements - a Vector with the initial Comparable objects
Returns:
a Vector of sorted Comparable objects NOTE:implements a simple Insertion Sort algorithm Sorts n element in place in O(n^2) worst-case time

mergeSort

public static java.util.Vector mergeSort(java.util.Vector comparables)
Parameters:
elements - a Vector with the initial Comparable objects
Returns:
a Vector of sorted Comparable objects NOTE:implements the Merge Sort algorithm Sorts n element in O(nlgn) worst-case time


This API and code belongs to the JavaPOS committee please see LISCENCE file for details