Skip to content

1.4.0

Latest

Choose a tag to compare

@kylehughes kylehughes released this 08 Jul 17:59

Added

  • Implemented Quicksort.
  • Implemented BubbleSort.
  • Implemented BuiltInSortingAlgorithmType to enumerate the sorting algorithms built into the library, including access to each algorithm's erased metatype.
  • Implemented minimum, maximum, and average number-of-comparisons calculations for all sorting algorithms.
  • Implemented isFinished property on sorting algorithms.
  • Made Element the primary associated type of SortingAlgorithm.

Changed

  • Made the number-of-comparisons calculations return Double instead of Int.
  • Made Comparison.callAsFunction() answer ties with the left side, which preserves the stability of stable sorting algorithms.

Fixed

  • Fixed the average number-of-comparisons calculations for InsertionSort and MergeSort, and the minimum for Quicksort, to be exact.
  • Fixed a crash when sorting an empty input with Quicksort.
  • Fixed a crash when peeking at an element in MergeSort right before the algorithm is finished.
  • Fixed answer(_:) and peekAtElement(for:) to have no effect when the algorithm is not at a point of comparison.