Opus5
Class AbstractSorter
java.lang.Object
|
+--Opus5.AbstractSorter
- All Implemented Interfaces:
- Sorter
- Direct Known Subclasses:
- AbstractQuickSorter, BinaryInsertionSorter, BubbleSorter, BucketSorter, HeapSorter, RadixSorter, StraightInsertionSorter, StraightSelectionSorter, TwoWayMergeSorter
- public abstract class AbstractSorter
- extends java.lang.Object
- implements Sorter
The AbstractSorter class is the base class
from which all concrete sorter classes are derived.
This abstract class provides default implementations
for various methods declared in the Sorter interface.
- Version:
- $Id: AbstractSorter.java,v 3.2 1998/07/28 13:08:33 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
- See Also:
Sorter
|
Field Summary |
protected Comparable[] |
array
The array to be sorted. |
protected int |
n
The length of the array to be sorted. |
|
Method Summary |
protected abstract void |
sort()
Sorts the array to which the array field refers. |
void |
sort(Comparable[] array)
Sorts the specified array of comparable objects
from "smallest" to "largest". |
protected void |
swap(int i,
int j)
Swaps the specified elements the array
to which the array field refers. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
array
protected Comparable[] array
- The array to be sorted.
n
protected int n
- The length of the array to be sorted.
AbstractSorter
public AbstractSorter()
sort
protected abstract void sort()
- Sorts the array to which the
array field refers.
sort
public final void sort(Comparable[] array)
- Sorts the specified array of comparable objects
from "smallest" to "largest".
Calls the abstract
sort method to do the actual sort.
- Specified by:
sort in interface Sorter
- Parameters:
The - array of objects to be sorted.- See Also:
sort()
swap
protected final void swap(int i,
int j)
- Swaps the specified elements the array
to which the
array field refers.