public abstract static class SortApp.SortAlgorithm
extends java.lang.Object
SortApp
object must
extend this embedded class SortApp.SortAlgorithm
.SortApp
object was a decision due to
Applet problems with inner classes at least up to 2005. An inner
class would, of course, be the natural choice here.SortApp
Modifier and Type | Field and Description |
---|---|
protected boolean |
stopRequested
Stop request.
|
Modifier | Constructor and Description |
---|---|
protected |
SortAlgorithm()
Constructor for embedding class.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getMaxPossiVal()
Highest possible random value of array elements.
|
protected boolean |
pause()
Have a break / make a pause.
|
protected boolean |
pause(int item1)
Have a break / make a pause.
|
protected boolean |
pause(int item1,
int item2)
Have a break / make a pause and mark the sorting step.
|
protected abstract void |
sort(int[] a)
The real sorting method.
|
static void |
startMe()
Make an inheritor startable in an uniform way.
|
void |
stop()
Stop the sorting.
|
protected boolean |
swap(int item1,
int item2)
A swap with pause and mark the sorting step.
|
protected final int getMaxPossiVal()
protected final boolean pause()
pause(int, int)
protected final boolean pause(int item1)
pause(int, int)
protected final boolean pause(int item1, int item2)
sort(int[])
) after every
(substantial) step. The parameters item1 and item2 are markers / indices
in the array describing the current sorting state.item1
- Index A in the array to be sorted relating to the step / stateitem2
- Index B in the array to be sorted relating to the step / stateprotected final boolean swap(int item1, int item2)
marks
this step.pause(int, int)
directly
-1 or other out of bound values to omit or hide ar marker are forbidden
here.
item1
- Index A of one element to be swappeditem2
- Index B of one element to be swappedpublic void stop()
stopRequested
true.
Implementations of sort(int[])
must react accordingly.protected abstract void sort(int[] a)
pause(int, int)
, pause(int)
, pause()
directly
or indirectly by utilising swap(int, int)
for element
exchanges within the array having been provided to this
sort
implementation. pausing
does all else like counting steps,
displaying the sorting state and else.public static void startMe()
SortApp.main(String[])