kiwi.util
Class MergeSort
java.lang.Object
|
+--kiwi.util.MergeSort
- Direct Known Subclasses:
- StringMergeSort
- public abstract class MergeSort
- extends Object
An implementation of MergeSort, which can be subclassed to provide a
comparator.
- Version:
- 1.0 (10/98)
- Author:
- Scott Violet
Constructor Summary |
MergeSort()
Construct a new MergeSort . |
Method Summary |
abstract int |
compareElementsAt(int beginLoc,
int endLoc)
Compare two elements. |
void |
sort(Object[] array)
Sort an array of objects. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
toSort
protected Object[] toSort
- The array to sort.
MergeSort
public MergeSort()
- Construct a new
MergeSort
.
sort
public void sort(Object[] array)
- Sort an array of objects.
- Parameters:
array
- The array to sort.
compareElementsAt
public abstract int compareElementsAt(int beginLoc,
int endLoc)
- Compare two elements.
- Returns:
- A negative value if
toSort[beginLoc]
is "less" than
toSort[endLoc]
, a positive value if it is "greater", or
0 if they are equal. - See Also:
toSort