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 a View 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):

    1. creates the SortCoordinator object
    2. calls execute() when user is tapping some element in the UI
    3. reacts to the events in the SortCoordinator when the array within changes, by updating the UI
    4. 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 SortMethod protocol which all the sorting methods implement.

    See more

    Declaration

    Swift

    class SortCoordinator : ObservableObject