Opus5
Class TwoWayMergeSorter
java.lang.Object
|
+--Opus5.AbstractSorter
|
+--Opus5.TwoWayMergeSorter
- All Implemented Interfaces:
- Sorter
- public class TwoWayMergeSorter
- extends AbstractSorter
Sorter for sorting an array of Comparable objects.
Implements two-way merge sort.
- Version:
- $Id: TwoWayMergeSorter.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
- See Also:
Comparable
|
Method Summary |
protected void |
merge(int left,
int middle,
int right)
Merges two sorted subsequences of the array into one. |
protected void |
sort()
Sorts the array of comparable objects. |
protected void |
sort(int left,
int right)
Sorts the specified range of positions in the array. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TwoWayMergeSorter
public TwoWayMergeSorter()
merge
protected void merge(int left,
int middle,
int right)
- Merges two sorted subsequences of the array into one.
- Parameters:
left - The first position of the left subsequence.middle - The first position of the right subsequence.
The last position in the left subsequences is middle-1.right - The last position of the right subsequence.
sort
protected void sort()
- Sorts the array of comparable objects.
- Overrides:
sort in class AbstractSorter
sort
protected void sort(int left,
int right)
- Sorts the specified range of positions in the array.
- Parameters:
left - The position of the left end of the range to be sorted.right - The position of the right end of the range to be sorted.