|
ADS
Algorithms and Data Structures
|
The internal sorts of Knuth that the book leaves out, beyond the book: More...
#include "ADS/Contract.h"#include "ADS/sort/RadixSort.h"#include "ADS/sort/Sorted.h"#include <algorithm>#include <cmath>#include <cstddef>#include <functional>#include <optional>#include <type_traits>#include <utility>#include <vector>#include "ADS/sort/impl/KnuthSorts.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| template<RankStore Store, class T = std::ranges::range_value_t< std::remove_cvref_t< Store > >, class C = std::less<>> | |
| void | ADS::binaryInsertionSort (Store &&A, C less=C()) |
| the binary insertion sort | |
| template<class T, class C = std::less<>> | |
| void | ADS::binaryInsertionSort (std::vector< T > &A, C less=C()) |
| binaryInsertionSort() above on a vector | |
| template<RankStore Store, class T = std::ranges::range_value_t< std::remove_cvref_t< Store > >, class C = std::less<>> | |
| void | ADS::listInsertionSort (Store &&A, C less=C(), std::size_t *moves=nullptr) |
| the list insertion sort; the moves of the items go to *moves, if given | |
| template<class T, class C = std::less<>> | |
| void | ADS::listInsertionSort (std::vector< T > &A, C less=C(), std::size_t *moves=nullptr) |
| listInsertionSort() above on a vector | |
| template<RankStore Store, class T = std::ranges::range_value_t< std::remove_cvref_t< Store > >> | |
| void | ADS::addressCalculationSort (Store &&A, std::size_t M=0) |
| the address calculation sort of numbers into \( M \) lists, \( M = \lfloor n / 4 \rfloor + 1 \) if \( M \) is 0; with an infinite range (an infinity, or a span beyond a double) all the items go to one list, an insertion sort | |
| template<class T> | |
| void | ADS::addressCalculationSort (std::vector< T > &A, std::size_t M=0) |
| addressCalculationSort() above on a vector | |
| template<RankStore Store, RadixKey T = std::ranges::range_value_t< std::remove_cvref_t< Store > >> | |
| void | ADS::radixExchangeSort (Store &&A) |
| the radix exchange sort | |
| template<RadixKey T> | |
| void | ADS::radixExchangeSort (std::vector< T > &A) |
| radixExchangeSort() above on a vector | |
| template<RankStore Store, class T = std::ranges::range_value_t< std::remove_cvref_t< Store > >, class C = std::less<>> | |
| void | ADS::tournamentSort (Store &&A, C less=C()) |
| the tournament sort | |
| template<class T, class C = std::less<>> | |
| void | ADS::tournamentSort (std::vector< T > &A, C less=C()) |
| tournamentSort() above on a vector | |
| template<RankStore Store, class T = std::ranges::range_value_t< std::remove_cvref_t< Store > >, class C = std::less<>> | |
| void | ADS::mergeInsertionSort (Store &&A, C less=C()) |
| the merge insertion sort of Ford and Johnson | |
| template<class T, class C = std::less<>> | |
| void | ADS::mergeInsertionSort (std::vector< T > &A, C less=C()) |
| mergeInsertionSort() above on a vector | |
| long | ADS::fordJohnsonBound (std::size_t n) |
| the worst case of the comparisons of mergeInsertionSort() on \( n \) items, \( \sum_{k=1}^{n} \lceil \log_2 ( 3 k / 4 ) \rceil \) | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { binaryInsertionSort( v , std::forward< P > ( p )... ); } | |
| decltype(auto) | ADS::binaryInsertionSort (R &&A, P &&... p) |
| binaryInsertionSort() on the range \( A \) [see SortRange], the other arguments as for a vector, in place: on the span of its items if \( A \) is contiguous, on its view otherwise, since the sort reads the items by their ranks only | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { listInsertionSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::listInsertionSort (R &&A, P &&... p) |
| listInsertionSort() on the range \( A \) [see SortRange], the other arguments as for a vector, in place: on the span of its items if \( A \) is contiguous, on its view otherwise, since the sort reads the items by their ranks only | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { addressCalculationSort( v , std::forward< P > ( p )... ); } | |
| decltype(auto) | ADS::addressCalculationSort (R &&A, P &&... p) |
| addressCalculationSort() on the range \( A \) [see SortRange], the other arguments as for a vector, in place: on the span of its items if \(A \) is contiguous, on its view otherwise, since the sort reads the items by their ranks only | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { radixExchangeSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::radixExchangeSort (R &&A, P &&... p) |
| radixExchangeSort() on the range \( A \) [see SortRange], the other arguments as for a vector, in place: on the span of its items if \( A \) is contiguous, on its view otherwise, since the sort reads the items by their ranks only | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { tournamentSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::tournamentSort (R &&A, P &&... p) |
| tournamentSort() on the range \( A \) [see SortRange], the other arguments as for a vector, in place: on the span of its items if \( A \) is contiguous, on its view otherwise, since the sort reads the items by their ranks only | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { mergeInsertionSort( v , std::forward< P > ( p )... ); } | |
| decltype(auto) | ADS::mergeInsertionSort (R &&A, P &&... p) |
| mergeInsertionSort() on the range \( A \) [see SortRange], the other arguments as for a vector, in place: on the span of its items if \( A \) is contiguous, on its view otherwise, since the sort reads the items by their ranks only | |
The internal sorts of Knuth that the book leaves out, beyond the book:
The contracts [see Contract.h]: each sort ends with the same items sorted, an audit. The functions are defined in KnuthSorts.tpp.