org.melati.poem.util
Class SortUtils

Package class diagram package SortUtils
java.lang.Object
  extended by org.melati.poem.util.SortUtils

public final class SortUtils
extends Object

An assortment of useful sorting operations.


Method Summary
static void insertionSort(Order cmp, Object[] arr)
          Sort an Array by a supplied ordering.
static void qsort(Order cmp, Object[] arr)
          Quick sort an array.
static Object[] sorted(Order cmp, Enumeration e)
          Sort an Enumeration into an Array.
static Object[] sorted(Order cmp, Object[] arr)
          Return a new sorted Array.
static Object[] sorted(Order cmp, Vector v)
          Sort a Vector into a new Array.
static void swap(Object[] arr, int i, int j)
          Swap two elements of an Array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

swap

public static void swap(Object[] arr,
                        int i,
                        int j)
Swap two elements of an Array.

Parameters:
arr - the Array
i - will become j
j - will become i

insertionSort

public static void insertionSort(Order cmp,
                                 Object[] arr)
Sort an Array by a supplied ordering.

Parameters:
cmp - an ordering
arr - the Array to sort

qsort

public static void qsort(Order cmp,
                         Object[] arr)
Quick sort an array.

Parameters:
cmp - ordering to use
arr - Array to sort

sorted

public static Object[] sorted(Order cmp,
                              Object[] arr)
Return a new sorted Array.

Parameters:
cmp - the ordering
arr - the Array to sort
Returns:
the sorted Array

sorted

public static Object[] sorted(Order cmp,
                              Vector v)
Sort a Vector into a new Array.

Parameters:
cmp - the ordering
v - Vector to sort
Returns:
an Array of the sorted Vector's Elements

sorted

public static Object[] sorted(Order cmp,
                              Enumeration e)
Sort an Enumeration into an Array.

Parameters:
cmp - the ordering
e - the Enumeration to sort
Returns:
an Array of the sorted Enumeration's Elements


Copyright © 2000-2010 PanEris. All Rights Reserved.