FlexOr.searchAndSort
Class SelectionObs
java.lang.Object
java.util.Observable
FlexOr.searchAndSort.SortObservable
FlexOr.searchAndSort.SelectionObs
- All Implemented Interfaces:
- ArraySort, java.lang.Runnable
public class SelectionObs
- extends SortObservable
- implements ArraySort
An observable sort of an array of objects using selection sort. Observers
can monitor the progress of the sort in particular for describing the sort
algorithm through animation. It is assumed the observers get a copy of the
array and only need to be informed about which array entries are being compared.
and which are being swapped.
- Version:
- 1.0 1999 Jan 15
- Author:
- Gunnar Gotshalks
Methods inherited from class java.util.Observable |
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SelectionObs
public SelectionObs(java.lang.Object[] array,
BinaryPredicate bp)
sort
public void sort(java.lang.Object[] array,
BinaryPredicate bp)
- Specified by:
sort
in interface ArraySort
- Parameters:
array
- Array of elements to be sorted.bp
- Defines how array elements are compared.
execute
public void execute(java.lang.Object[] array,
BinaryPredicate bp)
- The selection sort method.
Loop invariant:
for i : 0..array.length :: ( sorted(array[0..i-1])
and for j = i .. arrayLength-1 :: array[i-1] bp array[j] )
- Specified by:
execute
in class SortObservable
- Parameters:
array
- Array of elements to be sorted.bp
- Defines how array elements are compared.