52 #define __ADS_Heapsort
97 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
98 class C = std::less<> >
103template<
class T ,
class C = std::less<> >
120 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
121 class C = std::less<> >
125template<
class T ,
class C = std::less<> >
144 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
145 class C = std::less<> >
149template<
class T ,
class C = std::less<> >
150void heapsort( std::vector< T > & A , C less = C() );
156 class T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
157 class C = std::less<> >
158bool isMaxHeap( Store && A , std::size_t dim , C less = C() );
161template<
class T ,
class C = std::less<> >
162bool isMaxHeap(
const std::vector< T > & A , std::size_t dim , C less = C() );
173 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
175{
heapsort( v , std::forward< P >( p )... ); }
178 const auto f = [ & ](
auto & v ) ->
decltype(
auto ) {
179 return(
heapsort( v , std::forward< P >( p )... ) );
181 return( detail::sortRange( A , f , f ) );
192#include "ADS/sort/impl/Heapsort.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 heapBuild(Store &&A, C less=C())
made a max-heap, time
void maxHeapRestore(Store &&A, std::size_t i, std::size_t dim, C less=C())
moved down in the heap , with the order less, extra space
void heapsort(Store &&A, C less=C())
in increasing order, time
bool isMaxHeap(Store &&A, std::size_t dim, C less=C())
true if is a max-heap, i.e., if no item is larger than its parent