Protocols
The following protocols are available globally.
-
A common protocol for all sorting methods.
Note that the array to be sorted is hosted in an external object, and provided to the sorting methods as a parameter to the
nextStep()
method. Each execution of the nextStep() executes one relevant step of the sorting algorithm, usually leading into values changing places in the array to be sorted. This can then be animated in the UI.Protocol implementations must also implement
realAlgorithm()
, executing the sorting method in a tight loop. This is not animated in the UI, but used in comparing the speed of the algorithms.Note that when giving an array to be sorted to various sorting methods, the array each of them starts with must contain the same numbers in the same order – otherwise the comparisons are not fair.
See moreDeclaration
Swift
protocol SortMethod
-
An interface for stack data structure needed by e.g. LampSort.
Based on an example from Stackoverflow.
See https://stackoverflow.com/questions/31462272/stack-implementation-in-swift
See moreDeclaration
Swift
protocol Stackable