|
ADS
Algorithms and Data Structures
|
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the audits are on (ADS_CONTRACTS at least 3), and the check that the output is sorted and holds the same items as the input, which sorts a copy of the input with std::sort and compares the two item by item through the equivalence of the order, in \( O( n \log n ) \) time instead of the \( O( n^2 ) \) of std::is_permutation with a predicate; and the check that a sequence is sorted. More...
#include "ADS/Contract.h"#include "ADS/Portable.h"#include <algorithm>#include <cstddef>#include <functional>#include <iterator>#include <ranges>#include <span>#include <string>#include <type_traits>#include <utility>#include <vector>#include "ADS/sort/impl/Sorted.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Concepts | |
| concept | ADS::SortRange |
| a range that the sorts take beside std::vector and std::span: random access, sized, its items movable in and out of it [see above] | |
| concept | ADS::SortStore |
| the storage on which the sorts work in place, by reference: a std::vector or a std::span of its items, read by their addresses | |
| concept | ADS::RankStore |
| the storage on which the sorts of the book work in place, which read the items by their ranks only: a SortStore, or the view of a random-access range that is not contiguous | |
| concept | ADS::StringStore |
| a SortStore of strings | |
Macros | |
| #define | ADS_SORT_FORWARD ADS_ALWAYS_INLINE |
Functions | |
| bool | ADS::checkingContract (void) |
| true while a contract of ADS is evaluated: a comparator that counts its calls skips those made by the contracts | |
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the audits are on (ADS_CONTRACTS at least 3), and the check that the output is sorted and holds the same items as the input, which sorts a copy of the input with std::sort and compares the two item by item through the equivalence of the order, in \( O( n \log n ) \) time instead of the \( O( n^2 ) \) of std::is_permutation with a predicate; and the check that a sequence is sorted.
These checks call the comparator of the caller, so that checkingContract() tells a comparator that counts its calls, as those of the tests of the book, which calls come from a contract. The functions are defined in Sorted.tpp.
SortRange is the range that the sorts of ADS take beside the std::vector of the book and the std::span on which they work: a random-access range of movable items, sized and writable, such as an array, a std::deque, a TieredVector or the vectors of Boost and Eigen (sortRange()). A contiguous range is sorted in place, as the span of its items. A range that is not contiguous is sorted in place by the sorts that read the items only by their ranks (those of the book), on the view of its items, and through a vector of its items by the others, whose code reads the items by their addresses (\( 2 n \) moves and \( n \) items of memory beyond the sort), as the comment of each says. The sorts themselves are templates on the storage of the items, taken by reference (SortStore, a vector or a span, and RankStore, which adds the views, for the sorts of the book), and each overload on a std::vector is one call of the same template on the vector, inlined (ADS_SORT_FORWARD), so that it runs the code it ran before the ranges.
| #define ADS_SORT_FORWARD ADS_ALWAYS_INLINE |