Classes
The following classes are available globally.
-
SortCoordinator coordinates, as the name implies, sorting of arrays using different sorting methods. It is an
ObservableObject
, being observerd by aView
that holds the coordinator as an@ObservedObject
to show the state of the sorting in the UI.SortCoordinator:
- holds the array to be sorted, giving it to each sort method by calling SortMethod.nextStep().
- times the sorting process using a
Timer
- publishes the array to the Views so that when the array is updated, view is redrawn.
- collects the timing results using
SortMethod.realAlgorithm(...)
, to show to the user the time the algoritms take to sort the array without any animations.
SortCoordinator is to be used so that the client (a SwiftUI View):
- creates the SortCoordinator object
- calls
execute()
when user is tapping some element in the UI - reacts to the events in the SortCoordinator when the array within changes, by updating the UI
- calls
stop()
if user wants to stop the sorting by tapping in the View.
For details, see the properties and methods in this class as well as the
See moreSortMethod
protocol which all the sorting methods implement.Declaration
Swift
class SortCoordinator : ObservableObject