|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.tools.Sort
public abstract class Sort
Generic class that implements the quicksort algorithm. Extending classes have to implement the abstract methods so that the sorting algorithm can perform the appropriate modifications to the extending class's datastructure.
| Constructor Summary | |
|---|---|
Sort()
|
|
| Method Summary | |
|---|---|
protected abstract int |
compare(Object element1,
Object element2)
Compares the entries, determining which one comes before the other. |
protected abstract Object |
elementAt(Object dataToSort,
int position)
Retrieves an entry from a certain position within the specified datastructure. |
protected void |
quickSort(Object dataToSort,
int lo0,
int hi0,
boolean ascending)
This method contains the actual sorting algorithm. |
void |
sort(Object dataToSort,
int lastElementPosition,
boolean ascending)
Starts the sorting of the provided datastructure. |
protected abstract void |
swap(Object dataToSort,
int position1,
int position2)
Swaps the position of two entries in the provided datastructure. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Sort()
| Method Detail |
|---|
public final void sort(Object dataToSort,
int lastElementPosition,
boolean ascending)
dataToSort - An Object instance that points to the
datastructure that has to be sorted. The extending class should know how
to manipulate this particular datastructure.lastElementPosition - An integer that specifies the position of the
last element in the provided datastructure.ascending - true of the data has to be sorted in an ascending
fashion and false otherwise
protected final void quickSort(Object dataToSort,
int lo0,
int hi0,
boolean ascending)
dataToSort - An Object instance that points to the
datastructure that has to be sorted.lo0 - An integer indicating the bottom boundary of the range that
will be sorted.hi0 - An integer indicating the upper boundary of the range that
will be sorted.ascending - true of the data has to be sorted in an ascending
fashion and false otherwise
protected abstract void swap(Object dataToSort,
int position1,
int position2)
dataToSort - An Object instance that points to the
datastructure in which the entries have to be swapped.position1 - An integer with the position of the first entry.position2 - An integer with the position of the second entry.
protected abstract Object elementAt(Object dataToSort,
int position)
dataToSort - An Object instance that points to the
datastructure from where the entry has to be retrieved.position - An integer with the position of the entry that has to be
retrieved.
Object instace containing the entry at the
specified position.
protected abstract int compare(Object element1,
Object element2)
element1 - An Object instance containing the first
entry.element2 - An Object instance containing the second
entry.
0 if the two entries are equals; or
an integer <0 if the first entry comes before the second
one; or
an integer >0 if the first entry comes after the second
one
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||