Class Sort
public abstract class Sort
{
// Constructors
protected Sort();
protected void doSort(int lo, int size);
// Methods
protected int compare(int p, int q);
protected void swap(int p, int q);
}
This class implements an abstract sorting engine. The Sort class is a base class for implementing container-specific sorts. For examples of subclasses of Sort, see com.ms.util.VectorSort or com.ms.util.ArraySort.
protected Sort();
Constructs an instance of Sort.
protected void doSort(int lo, int size);
Sorts a range of elements.
Return Value:
No return value.
Parameter | Description |
lo
| The index of the first element to be sorted.
|
size
| The number of elements to be sorted.
|
protected int compare(int p, int q);
Called when the sorting engine must compare two elements. Subclasses override this method in a container-specific manner.
Return Value:
Returns an integer describing the relationship of the elements.
If Sort returns less than 0, place element p before element q in the sort.
If Sort returns greater than 0, place element p after element q.
If Sort returns 0, elements p and q are equivalent.
Parameter | Description |
p
| The index of the first operand of the comparison.
|
q
| The index of the second operand of the comparison.
|
protected void swap(int p, int q);
Called when the sorting engine must swap two elements. Subclasses override this method in a container-specific manner.
Return Value:
No return value.
Parameter | Description |
p
| The index of the first operand of the swap operation.
|
q
| The index of the second operand of the swap operation.
|