- This version is based on a class InsertionSort, that makes
it possible to
sort an array of objects. The method of comparison is given using a handle. The test class TestSort shows how to use
the sort. Please note the anonymous
inner class extending the class InsertionSort.
- In this version, InsertionSort sorts arrays
of objects implementing an interface Comparable. The classes TestSort and ComparableInt show how to
use this version.
- In this version, we use the generic interface java.lang.Comparable. The
class InsertionSort has been
adapted, in the same way as TestSort.
- In this version, we have a new sorting class at our disposal: QuickSort. An interface Sort has been added to
allow an undifferentiated use of sorts, and InsertionSort
has been modified to implement this interface. TestSort has also been
- This version adds an interface SortableData, given a type
for sortable data. Two implementations have been proposed : SortableArray and SortableList which adapts
respectively arrays and instances of List
containing comparable objects. SortableArray
and SortableList share
code thanks to the abstract
class SortableComparableData. The
classes Sort, QuickSort, InsertionSort, and TestSort have been modified
in order to use instances of SortableData
(see the UML diagram).
- This version makes it possible to modify the sort order, or more
to add a comparison function to objects which are not naturally
comparable. It is based on the class java.util.Comparator.
The classes Sort, InsertionSort and QuickSort remain unchanged.
Contrariwise, the architecture around SortableData have been
deeply modified (see the UML
diagram). We now find the
ComparableData, SwapableData, the classes SwapableArray and SwapableList, the abstract
class ComparableSwapableData, and the two classes SortableComparableData and SortableDataWithComparator.
The class Comparators makes it
combine two instances of Comparator
in a lexicographic way, to invert a Comparator, and to have a
comparator available from comparable data.
The classes TestLexicographic and People allow to sort
people by their name and first name.
- This version adds a tracing functionality (print on stdout the comparisons and the
exchanges) or a statistics functionality (count comparisons and
thanks to decorators SortableDataWithTracer and SortableDataWithStatistics
(see the UML diagram). The codes of these two
classes have been factorized using an abstract and not public class SortableDataDelegation. The
class TestSort has also been
- This version helps to use the package
providing a "facade" with the class Sorts (for example, if the
user just wants to sort an array using quicksort, he doesn't need to
understand how to use classes like
SortableData). TestSort has also been
- This version provides a class ObservableSortableData
which decorates SortableData
by making instances observable. This version is based on the model
Observer/Observable, implemented in the Java API by the classes java.util.Observable and java.util.Observer. Please
note that this decoration cannot extend SortableDataDelegation because
it must inherit from java.util.Observable.
this case, the lack of a corresponding interface makes
the delegation impossible. Two classes of observer are proposed : one
the sort on the standard output (AsciiTracer), the other for
tracing the sort in a graphical window (WinTracer). TestSort has also been
modified. Please note the use of a public internal class in ObservableSortableData, the
- This version makes it possible to dynamically load the class used
sorting. The name of the sort is given as the first parameter of the
Only the class TestSort has been modified.
- This version makes it possible to visualize at the same time and
in parallel several sorts' algorithms into a graphical window. A
subpackage sort.trace has
been added to
separate the classes devoted to vizualisation. Inside
find the class AsciiTracer,
unchanged except at the package line, the class WinTracer which is no more
JFrame (an autonomous window), but just a
(a graphical component). This subpackage also contains the class MultipleWinTracer which
groups the panels of the different sorts, the slider which controls the
speed of the execution, and also manages the threads executing the
sorts. The class TestSort has also changed.
The rest remains the same.