sorting.Sort Class Reference

The Sort class is the super class for all sorting classes in this package. More...

Inherited by sorting.BubbleSort, sorting.InsertionSort, and sorting.SelectionSort.

Inheritance diagram for sorting.Sort:

Inheritance graph
[legend]
List of all members.

Public Member Functions

void run ()
 This function is automatically executet when starting the thread.
int[] getSortedArray ()
 This function returns the integer array theArray.
void showArray ()
 This function is used to visualize the integer numbers of the integer array by painting the numbers as vertical green lines.
void setSettings (int[] aArray, Panel aPanel, Label aLabel)
 This function is used to set the attributes theArray, thePanel and theLabel.

Protected Member Functions

void doSort ()
 This is just a empty sorting function to be overloaded by child classes.
void exchange (int[] aArray, int index1, int index2)
 This function changes the positions of two array elements.
long calcRuntime ()
 This function calculates the runtime of the thread.

Protected Attributes

long startTime = 0
long endTime = 0
long runTime = 0
int[] theArray
Panel thePanel
Label theLabel

Detailed Description

The Sort class is the super class for all sorting classes in this package.

This class provides some functions and attributes, which are used by all child classes. For example, each sorting algorithm in this package uses a exchange() function to change the positions of two array elements. So this function is implemented once in this super class and then inherited to each child class. But this super class provides only an empty sorting function - this function must be overloaded by child classes with different sorting algorithms (therefore it makes no sense to create instances of this super class and therfore this is an abstract class).

Definition at line 26 of file Sort.java.


Member Function Documentation

long sorting.Sort.calcRuntime  )  [protected]
 

This function calculates the runtime of the thread.

Returns:
- returns the time, since thread has been started in milliseconds

Definition at line 91 of file Sort.java.

References sorting.Sort.startTime.

Referenced by sorting.SelectionSort.doSort(), sorting.InsertionSort.doSort(), sorting.BubbleSort.doSort(), and sorting.Sort.run().

void sorting.Sort.doSort  )  [protected]
 

This is just a empty sorting function to be overloaded by child classes.

Child classes overload this function with own doSort() functions and different algorithms.

Reimplemented in sorting.BubbleSort, sorting.InsertionSort, and sorting.SelectionSort.

Definition at line 67 of file Sort.java.

Referenced by sorting.Sort.run().

void sorting.Sort.exchange int[]  aArray,
int  index1,
int  index2
[protected]
 

This function changes the positions of two array elements.

Parameters:
aArray - an integer array
index1 - the 1st position
index2 - the 2nd position

Definition at line 79 of file Sort.java.

int [] sorting.Sort.getSortedArray  ) 
 

This function returns the integer array theArray.

This function is used to get access to the sortet integer numbers.

Returns:
- returns the integer array theArray

Definition at line 57 of file Sort.java.

void sorting.Sort.run  ) 
 

This function is automatically executet when starting the thread.

The run() function calls the doSort() function, which is overloaded by child classes.

Definition at line 41 of file Sort.java.

References sorting.Sort.calcRuntime(), and sorting.Sort.doSort().

Here is the call graph for this function:

void sorting.Sort.setSettings int[]  aArray,
Panel  aPanel,
Label  aLabel
 

This function is used to set the attributes theArray, thePanel and theLabel.

Parameters:
aArray - an integer array to be sorted
aPanel - a panel, where graphical visualition of the array shall occour during sorting
aLabel - a label, where to show the running time

Definition at line 123 of file Sort.java.

Referenced by DoxygenExample.sortArrays(), DoxygenExample.startBubbleSort(), DoxygenExample.startInsertionSort(), and DoxygenExample.startSelectionSort().

void sorting.Sort.showArray  ) 
 

This function is used to visualize the integer numbers of the integer array by painting the numbers as vertical green lines.

Note:
: This function requires, that the setSettings() function has been called previously.

Definition at line 101 of file Sort.java.

References sorting.Sort.theArray, and sorting.Sort.thePanel.


Member Data Documentation

long sorting.Sort.endTime = 0 [protected]
 

Definition at line 29 of file Sort.java.

long sorting.Sort.runTime = 0 [protected]
 

Definition at line 30 of file Sort.java.

long sorting.Sort.startTime = 0 [protected]
 

Definition at line 28 of file Sort.java.

Referenced by sorting.Sort.calcRuntime().

int [] sorting.Sort.theArray [protected]
 

Definition at line 32 of file Sort.java.

Referenced by sorting.SelectionSort.doSort(), sorting.InsertionSort.doSort(), sorting.BubbleSort.doSort(), and sorting.Sort.showArray().

Label sorting.Sort.theLabel [protected]
 

Definition at line 34 of file Sort.java.

Panel sorting.Sort.thePanel [protected]
 

Definition at line 33 of file Sort.java.

Referenced by sorting.Sort.showArray().


The documentation for this class was generated from the following file:
Generated on Thu Jun 22 19:07:32 2006 for Doxygen Example (Java) by  doxygen 1.4.5