|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tffenterprises.util.AbstractMergeSort
public abstract class AbstractMergeSort
AbstractMergeSort implements a merge sort, minus the comparison function. Inspired by a Sun example.
Field Summary | |
---|---|
protected java.lang.Object[] |
arrayToSort
An array of objects to sort. |
protected java.lang.Object[] |
scratch
An array of scratch space. |
Constructor Summary | |
---|---|
AbstractMergeSort()
|
Method Summary | |
---|---|
protected abstract int |
compareElementsAt(int firstIndex,
int secondIndex)
The method that must be overridden to provide a comparison function. |
protected void |
merge(int beginIndex,
int middleIndex,
int endIndex)
The method that actually does the merge in merge sort. |
void |
mergeSort(int beginIndex,
int endIndex)
The recursive method for the merge sort. |
void |
sort(java.lang.Object[] arrayToSort)
Sorts (in place) an array of objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Object[] arrayToSort
protected java.lang.Object[] scratch
Constructor Detail |
---|
public AbstractMergeSort()
Method Detail |
---|
public void sort(java.lang.Object[] arrayToSort)
arrayToSort
- The array to sort.public void mergeSort(int beginIndex, int endIndex)
beginIndex
- The index at which to begin sorting.endIndex
- The index at which to end sorting.protected void merge(int beginIndex, int middleIndex, int endIndex)
beginIndex
- The starting index of the first half to merge.middleIndex
- The ending index of the first half to merge.endIndex
- The ending index of the second half to merge.protected abstract int compareElementsAt(int firstIndex, int secondIndex)
firstIndex
- The index of the first element to compare.secondIndex
- The index of the second element to compare.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |