Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.util   Previous This
Package
Next

 


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.

Constructors

Sort

protected Sort();

Constructs an instance of Sort.

doSort

protected void doSort(int lo, int size);

Sorts a range of elements.

Return Value:

No return value.

ParameterDescription
lo The index of the first element to be sorted.
size The number of elements to be sorted.

Methods

compare

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.

ParameterDescription
p The index of the first operand of the comparison.
q The index of the second operand of the comparison.

swap

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.

ParameterDescription
p The index of the first operand of the swap operation.
q The index of the second operand of the swap operation.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.