ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
TreeSort.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*---------------------------- File TreeSort.h -----------------------------*/
3/*--------------------------------------------------------------------------*/
28/*--------------------------------------------------------------------------*/
29/*----------------------------- DEFINITIONS --------------------------------*/
30/*--------------------------------------------------------------------------*/
31
32#ifndef __ADS_TreeSort
33 #define __ADS_TreeSort
34/* self-identification: #endif constant */
35
36/*--------------------------------------------------------------------------*/
37/*------------------------------ INCLUDES ----------------------------------*/
38/*--------------------------------------------------------------------------*/
39
40#include "ADS/Contract.h"
41#include "ADS/sort/Sorted.h"
42#include "ADS/tree/SearchTree.h"
43
44#include <algorithm>
45#include <concepts>
46#include <cstddef>
47#include <functional>
48#include <utility>
49#include <vector>
50
51/*--------------------------------------------------------------------------*/
52/*--------------------------- NAMESPACE ------------------------------------*/
53/*--------------------------------------------------------------------------*/
54
55namespace ADS
56{
57
77template< RankStore Store ,
78 std::totally_ordered T = std::ranges::range_value_t<
79 std::remove_cvref_t< Store > > >
80void treeSort( Store && A , bool balanced = true );
81
83template< std::totally_ordered T >
84void treeSort( std::vector< T > & A , bool balanced = true );
85
86/*--------------------------------------------------------------------------*/
87/*------------------------- THE SORTS OF A RANGE ---------------------------*/
88/*--------------------------------------------------------------------------*/
89
94template< SortRange R , class... P >
95 requires requires( std::vector< std::ranges::range_value_t< R > > & v ,
96 P &&... p )
97{ treeSort( v , std::forward< P >( p )... ); }
98decltype( auto ) treeSort( R && A , P &&... p )
99{
100 const auto f = [ & ]( auto & v ) -> decltype( auto ) {
101 return( treeSort( v , std::forward< P >( p )... ) );
102 };
103 return( detail::sortRange( A , f , f ) );
104 }
105
106/*--------------------------------------------------------------------------*/
107
108} // end( namespace ADS )
109
110/*--------------------------------------------------------------------------*/
111/*-------------------------- IMPLEMENTATION --------------------------------*/
112/*--------------------------------------------------------------------------*/
113
114#include "ADS/sort/impl/TreeSort.tpp"
115
116/*--------------------------------------------------------------------------*/
117
118#endif /* TreeSort.h included */
119
120/*--------------------------------------------------------------------------*/
121/*-------------------------- End File TreeSort.h ---------------------------*/
122/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The binary search tree (ABR) and the Red-Black tree of the book, as a DICTIONARY [see ADT....
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 treeSort(Store &&A, bool balanced=true)
the tree sort on a Red-Black tree, or on a search tree with no balance if balanced is false
Definition ADT.h:96