51#ifndef __ADS_ExchangeSorts
52 #define __ADS_ExchangeSorts
93 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
94 class C = std::less<> >
98template<
class T ,
class C = std::less<> >
121 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
122 class C = std::less<> >
126template<
class T ,
class C = std::less<> >
147 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
148 class C = std::less<> >
149void oddEvenSort( Store && A , C less = C() , std::size_t * rounds =
nullptr );
152template<
class T ,
class C = std::less<> >
154 std::size_t * rounds =
nullptr );
174 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
175 class C = std::less<> >
179template<
class T ,
class C = std::less<> >
180void combSort( std::vector< T > & A , C less = C() );
197 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
198 class C = std::less<> >
202template<
class T ,
class C = std::less<> >
214 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
216{
bubbleSort( v , std::forward< P >( p )... ); }
219 const auto f = [ & ](
auto & v ) ->
decltype(
auto ) {
220 return(
bubbleSort( v , std::forward< P >( p )... ) );
222 return( detail::sortRange( A , f , f ) );
229template< SortRange R ,
class... P >
230 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
237 const auto f = [ & ](
auto & v ) ->
decltype(
auto ) {
240 return( detail::sortRange( A , f , f ) );
247template< SortRange R ,
class... P >
248 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
255 const auto f = [ & ](
auto & v ) ->
decltype(
auto ) {
256 return(
oddEvenSort( v , std::forward< P >( p )... ) );
258 return( detail::sortRange( A , f , f ) );
265template< SortRange R ,
class... P >
266 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
268{
combSort( v , std::forward< P >( p )... ); }
271 const auto f = [ & ](
auto & v ) ->
decltype(
auto ) {
272 return(
combSort( v , std::forward< P >( p )... ) );
274 return( detail::sortRange( A , f , f ) );
281template< SortRange R ,
class... P >
282 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
284{
gnomeSort( v , std::forward< P >( p )... ); }
287 const auto f = [ & ](
auto & v ) ->
decltype(
auto ) {
288 return(
gnomeSort( v , std::forward< P >( p )... ) );
290 return( detail::sortRange( A , f , f ) );
301#include "ADS/sort/impl/ExchangeSorts.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
the storage on which the sorts of the book work in place, which read the items by their ranks only: a...
Definition Sorted.h:184
a range that the sorts take beside std::vector and std::span: random access, sized,...
Definition Sorted.h:153
void bubbleSort(S &s)
the bubble sort: at most passes of swaps of adjacent items out of order, stopped at the first pass w...
void combSort(Store &&A, C less=C())
the comb sort, the gap shrinking by 1.3
void gnomeSort(Store &&A, C less=C())
the gnome sort
void oddEvenSort(Store &&A, C less=C(), std::size_t *rounds=nullptr)
the odd-even transposition sort; the rounds go to *rounds, if given
void cocktailShakerSort(Store &&A, C less=C())
the bubble sort with passes in both directions