Structures
The following structures are available globally.
-
A decision about the inherent order of two elements being sorted by an algorithm.
A comparison presents two elements – left and right – whose order needs to be determined, accepts an answer for that decision, and produces the next state of the algorithm.
The inherent order of the elements is left to the caller. Whether an element is on the left or right is irrelevant. A comparison could be used to represent “greater than,” “less than,” “better than,” “worse than,” “talller than,” etc. As long as the answers to the comparisons are consistent the sorted outcome will reflect the intended order.
A comparison is technically a lense over an algorithm. It has no bespoke state itself.
See moreDeclaration
Swift
public struct Comparison<Algorithm> where Algorithm : SortingAlgorithm
extension Comparison: Codable where Algorithm: Codable
extension Comparison: Equatable where Algorithm: Equatable
extension Comparison: Hashable where Algorithm: Hashable
-
A simple sorting algorithm that sorts its elements one at a time.
See moreDeclaration
Swift
public struct InsertionSort<Element> : Identifiable
extension InsertionSort: SortingAlgorithm
extension InsertionSort: Codable where Element: Codable
extension InsertionSort: Equatable where Element: Equatable
extension InsertionSort: Hashable where Element: Hashable
-
Declaration
Swift
public struct MergeSort<Element> : Identifiable
extension MergeSort: SortingAlgorithm
extension MergeSort: Codable where Element: Codable
extension MergeSort: Equatable where Element: Equatable
extension MergeSort: Hashable where Element: Hashable
-
The type used to uniquely identify a sorting algorithm implementation.
See moreDeclaration
Swift
public struct SortingAlgorithmLabel : Codable, Equatable, Hashable, Identifiable