cynosurex.util
Class SortRoutines

java.lang.Object
  extended by cynosurex.util.SortRoutines
All Implemented Interfaces:
cynosurex.internal.AuthorCommon, cynosurex.internal.CommonInterface, cynosurex.internal.CompanyCommon

public class SortRoutines
extends java.lang.Object
implements cynosurex.internal.CommonInterface

This class provides a variety of sort algorithms to manipulate your data.

Version:
1.0
Author:
Chieh Cheng

Field Summary
 
Fields inherited from interface cynosurex.internal.CommonInterface
copyright, copyrightYears, notice, program, version
 
Fields inherited from interface cynosurex.internal.AuthorCommon
author, copyrightSymbol, noticeMsg, rights
 
Fields inherited from interface cynosurex.internal.CompanyCommon
company, email, website
 
Method Summary
static void bubbleSort(java.lang.Object[] objects, SortFilter filter)
           The Bubble Sort is always very slow, no matter what data it is sorting.
static void sort(java.lang.Object[] objects, SortFilter filter)
           This method is a generic sort routine that calls another sort algorithm in this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bubbleSort

public static void bubbleSort(java.lang.Object[] objects,
                              SortFilter filter)

The Bubble Sort is always very slow, no matter what data it is sorting. However, it allocates no new memory address space, which is good for machines with low memory.

A Bubble Sort always runs in n^2 time and is a very poor choice for a sorting algorithm in any circumstance.


sort

public static void sort(java.lang.Object[] objects,
                        SortFilter filter)

This method is a generic sort routine that calls another sort algorithm in this class. Its purpose is to point to the best sort algorithm as they are implemented, thus saving you the headache of changing your codes.

At times, there will be no "best" algorithm, since efficiency (speed) and memory allocation (space) are inversely proportional. This method will attempt to balance the the speed and the space by picking an algorithm with a better compromise.

If your program need a strict control on the speed or space issue, call a specific sort algorithm instead.

Currently, this method calls the Bubble Sort algorithm.