Crossfire JXClient, Trunk
Public Member Functions | Package Functions | Private Member Functions | List of all members
QSortAlgorithm Class Reference
Inheritance diagram for QSortAlgorithm:
Inheritance graph
Collaboration diagram for QSortAlgorithm:
Collaboration graph

Public Member Functions

void sort (int a[]) throws Exception
 
- Public Member Functions inherited from SortAlgorithm
void init ()
 
void setParent (SortItem p)
 
void stop ()
 

Package Functions

void QuickSort (int a[], int lo0, int hi0) throws Exception
 

Private Member Functions

boolean pauseTrue (int lo, int hi) throws Exception
 
void swap (int a[], int i, int j)
 

Additional Inherited Members

- Protected Member Functions inherited from SortAlgorithm
void pause () throws Exception
 
void pause (int H1) throws Exception
 
void pause (int H1, int H2) throws Exception
 
- Protected Attributes inherited from SortAlgorithm
boolean stopRequested = false
 

Detailed Description

A quick sort demonstration algorithm SortAlgorithm.java

Author
James Gosling
Kevin A. Smith

Definition at line 49 of file QSortAlgorithm.java.

Member Function Documentation

◆ pauseTrue()

boolean QSortAlgorithm.pauseTrue ( int  lo,
int  hi 
) throws Exception
private

A version of pause() that makes it easier to ensure that we pause exactly the right number of times.

Definition at line 55 of file QSortAlgorithm.java.

Referenced by QuickSort().

Here is the caller graph for this function:

◆ QuickSort()

void QSortAlgorithm.QuickSort ( int  a[],
int  lo0,
int  hi0 
) throws Exception
package

This is a generic version of C.A.R Hoare's Quick Sort algorithm. This will handle arrays that are already sorted, and arrays with duplicate keys.

If you think of a one dimensional array as going from the lowest index on the left to the highest index on the right then the parameters to this function are lowest index or left and highest index or right. The first time you call this function it will be with the parameters 0, a.length - 1.

Parameters
aan integer array
lo0left boundary of array partition
hi0right boundary of array partition

Definition at line 74 of file QSortAlgorithm.java.

References a, pauseTrue(), and swap().

Referenced by sort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort()

void QSortAlgorithm.sort ( int  a[]) throws Exception

This method will be called to sort an array of integers.

Reimplemented from SortAlgorithm.

Definition at line 136 of file QSortAlgorithm.java.

References a, and QuickSort().

Here is the call graph for this function:

◆ swap()

void QSortAlgorithm.swap ( int  a[],
int  i,
int  j 
)
private

Definition at line 127 of file QSortAlgorithm.java.

References a.

Referenced by QuickSort().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: