|
ADS
Algorithms and Data Structures
|
The sorts by the digits of the keys, beyond the book (which has Counting Sort and Pigeonhole Sort, the one-digit cases, in CountingSort.h and PigeonholeSort.h): More...
#include "ADS/Contract.h"#include "ADS/parallel/Scratch.h"#include "ADS/sort/EngineeredQuickSorts.h"#include "ADS/sort/InsertionSort.h"#include "ADS/sort/Sorted.h"#include "ADS/sort/VectorQuickSort.h"#include <algorithm>#include <array>#include <bit>#include <cstddef>#include <cstdint>#include <cstring>#include <functional>#include <memory>#include <string>#include <type_traits>#include <utility>#include <vector>#include "ADS/sort/impl/RadixSort.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Concepts | |
| concept | ADS::RadixKey |
| an integer or a floating point number of at most 8 bytes | |
Functions | |
| template<RadixKey T> | |
| auto | ADS::radixKey (T x) |
| the unsigned key of \( x \), whose order is the order of the numbers: the bits of \( x \) with the sign bit flipped for a signed integer, and for a floating point number all of them flipped if it is negative and the sign bit otherwise | |
| template<SortStore Store, RadixKey T = std::ranges::range_value_t< std::remove_cvref_t< Store > >> | |
| void | ADS::radixSort (Store &&A) |
| the LSD radix sort of numbers | |
| template<RadixKey T> | |
| void | ADS::radixSort (std::vector< T > &A) |
| radixSort() above on a vector | |
| template<SortStore Store, class T = std::ranges::range_value_t< std::remove_cvref_t< Store > >, class K> | |
| void | ADS::radixSortBy (Store &&A, K key) |
| the LSD radix sort of any items by the unsigned key( x ), stable | |
| template<class T, class K> | |
| void | ADS::radixSortBy (std::vector< T > &A, K key) |
| radixSortBy() above on a vector | |
| template<SortStore Store, RadixKey T = std::ranges::range_value_t< std::remove_cvref_t< Store > >> | |
| void | ADS::americanFlagSort (Store &&A) |
| the MSD radix sort of numbers in place | |
| template<RadixKey T> | |
| void | ADS::americanFlagSort (std::vector< T > &A) |
| americanFlagSort() above on a vector | |
| template<StringStore Store> | |
| void | ADS::msdRadixSort (Store &&A) |
| the MSD radix sort of strings | |
| void | ADS::msdRadixSort (std::vector< std::string > &A) |
| msdRadixSort() above on a vector | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { radixSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::radixSort (R &&A, P &&... p) |
| radixSort() 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, through a vector of its items otherwise, since the code of the sort reads the items by their addresses | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { radixSortBy( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::radixSortBy (R &&A, P &&... p) |
| radixSortBy() 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, through a vector of its items otherwise, since the code of the sort reads the items by their addresses | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { americanFlagSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::americanFlagSort (R &&A, P &&... p) |
| americanFlagSort() 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, through a vector of its items otherwise, since the code of the sort reads the items by their addresses | |
| template<SortRange R, class... P> requires requires( std::vector< std::ranges::range_value_t< R > > & v , P &&... p ) { msdRadixSort( v , std::forward< P >( p )... ); } | |
| decltype(auto) | ADS::msdRadixSort (R &&A, P &&... p) |
| msdRadixSort() 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, through a vector of its items otherwise, since the code of the sort reads the items by their addresses | |
Variables | |
| constexpr std::size_t | ADS::kFlagSmall = kVectorSort ? 8192 : 256 |
| the groups that americanFlagSort() leaves to a sort by comparisons are those of fewer items than this: many with the vector registers, whose quicksort beats the radix passes that it replaces, few otherwise | |
The sorts by the digits of the keys, beyond the book (which has Counting Sort and Pigeonhole Sort, the one-digit cases, in CountingSort.h and PigeonholeSort.h):
The contracts [see Contract.h]: each sort ends with the same items sorted, an audit. The functions are defined in RadixSort.tpp.