|
ADS
Algorithms and Data Structures
|
The sorts by exchanges of items, beyond the book, all in place: More...
#include "ADS/Contract.h"#include "ADS/sort/Sorted.h"#include <algorithm>#include <cstddef>#include <functional>#include <utility>#include <vector>#include "ADS/sort/impl/ExchangeSorts.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::bubbleSort (Store &&A, C less=C()) |
| the bubble sort, each pass ending at the last swap of the previous one | |
| template<class T, class C = std::less<>> | |
| void | ADS::bubbleSort (std::vector< T > &A, C less=C()) |
| bubbleSort() 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::cocktailShakerSort (Store &&A, C less=C()) |
| the bubble sort with passes in both directions | |
| template<class T, class C = std::less<>> | |
| void | ADS::cocktailShakerSort (std::vector< T > &A, C less=C()) |
| cocktailShakerSort() 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::oddEvenSort (Store &&A, C less=C(), std::size_t *rounds=nullptr) |
| the odd-even transposition sort; the rounds go to *rounds, if given | |
| template<class T, class C = std::less<>> | |
| void | ADS::oddEvenSort (std::vector< T > &A, C less=C(), std::size_t *rounds=nullptr) |
| oddEvenSort() 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::combSort (Store &&A, C less=C()) |
| the comb sort, the gap shrinking by 1.3 | |
| template<class T, class C = std::less<>> | |
| void | ADS::combSort (std::vector< T > &A, C less=C()) |
| combSort() 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::gnomeSort (Store &&A, C less=C()) |
| the gnome sort | |
| template<class T, class C = std::less<>> | |
| void | ADS::gnomeSort (std::vector< T > &A, C less=C()) |
| gnomeSort() above on a vector | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { bubbleSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::bubbleSort (R &&A, P &&... p) |
| bubbleSort() 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 ) { cocktailShakerSort( v , std::forward< P > ( p )... ); } | |
| decltype(auto) | ADS::cocktailShakerSort (R &&A, P &&... p) |
| cocktailShakerSort() 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 ) { oddEvenSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::oddEvenSort (R &&A, P &&... p) |
| oddEvenSort() 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 ) { combSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::combSort (R &&A, P &&... p) |
| combSort() 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 ) { gnomeSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::gnomeSort (R &&A, P &&... p) |
| gnomeSort() 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 sorts by exchanges of items, beyond the book, all in place:
The contracts [see Contract.h]: each sort ends with the same items sorted, an audit. The functions are defined in ExchangeSorts.tpp.