kblib 0.2.3
General utilities library for modern C++
|
{WIP} Provides a fast and generic sorting interface. More...
#include "algorithm.h"
#include "bits.h"
#include "fakestd.h"
#include "simple.h"
#include <bitset>
#include <numeric>
Go to the source code of this file.
Namespaces | |
namespace | kblib |
The main namespace in which all entities from kblib are defined. | |
namespace | kblib::detail_sort |
Enumerations | |
enum class | kblib::detail_sort::sort_direction { kblib::detail_sort::ascending , kblib::detail_sort::descending } |
Functions | |
template<typename RandomAccessIt , typename Compare = std::less<>> | |
constexpr auto | kblib::insertion_sort (const RandomAccessIt begin, const RandomAccessIt end, Compare &&compare={}) noexcept(noexcept(swap(*begin, *begin)) and noexcept(compare(*begin, *begin))) -> void |
In-place insertion sort. As is usual, it is stable. Provides as a guarantee that it will perform no moves on sorted input. More... | |
template<typename RandomAccessIt , typename RandomAccessIt2 , typename Compare = std::less<>> | |
constexpr auto | kblib::insertion_sort_copy (const RandomAccessIt begin, const RandomAccessIt end, const RandomAccessIt2 d_begin, const RandomAccessIt2 d_end, Compare &&compare={}) noexcept(noexcept(detail_algorithm::shift_backward(d_begin, d_begin, d_end)) and noexcept(*d_begin= *begin)) -> void |
Out-of-place insertion sort, which does not modify the input. Provides as a guarantee that it will perform no moves on sorted input. More... | |
template<typename RandomAccessIt , typename RandomAccessIt2 , typename Compare = std::less<>> | |
constexpr auto | kblib::adaptive_insertion_sort_copy (const RandomAccessIt begin, const RandomAccessIt end, const RandomAccessIt2 d_begin, const RandomAccessIt2 d_end, Compare &&compare={}) noexcept(noexcept(detail_algorithm::shift_backward(d_begin, d_begin, d_end)) and noexcept(*d_begin= *begin)) -> void |
An adaptive sort which, at the cost of some additional work (time complexity Θ(sqrt(n))), avoids quadratic behavior for reverse-sorted inputs (and, in fact, handles them in optimal time). It's still possible to fool it, but it requires a staggered input, which is a highly unlikely shape for random data. More... | |
template<typename T > | |
constexpr auto | kblib::byte_count (T) noexcept -> enable_if_t< std::is_integral< T >::value, std::size_t > |
template<typename T > | |
constexpr auto | kblib::byte_count (T *) noexcept -> std::size_t |
template<typename T > | |
constexpr auto | kblib::byte_count (const std::unique_ptr< T > &) noexcept -> std::size_t |
template<typename T > | |
constexpr auto | kblib::byte_count (const T &x) noexcept -> enable_if_t< is_linear_container_v< T > and(std::is_integral< typename T::value_type >::value or is_byte_v< T >) and sizeof(typename T::value_type)==1, std::size_t > |
constexpr auto | kblib::byte_count (...) -> void=delete |
template<typename T > | |
constexpr auto | kblib::get_byte_index (T x, std::size_t idx) noexcept -> enable_if_t< std::is_integral< T >::value, unsigned char > |
template<typename T > | |
constexpr auto | kblib::get_byte_index (const T &x, std::size_t idx) noexcept -> enable_if_t< std::is_enum< T >::value, unsigned char > |
template<typename T > | |
auto | kblib::get_byte_index (T *x, std::size_t idx) noexcept -> unsigned char |
template<typename T > | |
auto | kblib::get_byte_index (const std::unique_ptr< T > &x, std::size_t idx) noexcept -> unsigned char |
template<typename RandomAccessIt , typename Compare > | |
constexpr auto | kblib::detail_sort::sort (RandomAccessIt, const RandomAccessIt, Compare) -> void |
template<typename RandomAccessIt , typename Compare > | |
constexpr auto | kblib::detail_sort::stable_sort (RandomAccessIt, const RandomAccessIt, Compare) -> void |
template<typename RandomAccessIt , typename Compare , std::size_t small_size> | |
constexpr auto | kblib::detail_sort::merge_sort (RandomAccessIt begin, const RandomAccessIt end, Compare cmp) -> void |
template<typename RandomAccessIt , typename Compare , std::size_t small_size> | |
constexpr auto | kblib::detail_sort::heap_sort (RandomAccessIt begin, const RandomAccessIt end, Compare cmp) -> void |
template<sort_direction dir, typename RandomAccessIt , typename Projection > | |
constexpr auto | kblib::detail_sort::radix_sort_i (RandomAccessIt begin, const RandomAccessIt end, Projection proj) -> void |
template<sort_direction dir, typename RandomAccessIt , typename Projection > | |
constexpr auto | kblib::detail_sort::radix_sort_s (RandomAccessIt begin, const RandomAccessIt end, Projection proj) -> void |
template<std::size_t size> | |
constexpr auto | kblib::detail_sort::make_array_for (std::false_type) -> kblib::containing_ptr< std::array< std::size_t, size > > |
template<std::size_t size> | |
auto | kblib::detail_sort::make_array_for (std::true_type) -> kblib::heap_value< std::array< std::size_t, size+1 > > |
template<sort_direction dir, typename RandomAccessIt1 , typename RandomAccessIt2 , typename Projection > | |
constexpr auto | kblib::detail_sort::counting_sort (RandomAccessIt1 begin, const RandomAccessIt1 end, RandomAccessIt2 d_begin, Projection proj) -> void |
template<typename RandomAccessIt , typename UnaryOperation , typename BinaryPredicate > | |
constexpr auto | kblib::sort_transform (RandomAccessIt begin, RandomAccessIt end, UnaryOperation &&transform, BinaryPredicate &&compare) -> void |
Sorts a range after applying a transformation. More... | |
template<typename RandomAccessIt , typename UnaryOperation > | |
constexpr auto | kblib::sort_transform (RandomAccessIt begin, RandomAccessIt end, UnaryOperation &&transform) -> void |
template<typename RandomAccessIt , typename BinaryPredicate > | |
constexpr auto | kblib::sort (RandomAccessIt begin, RandomAccessIt end, BinaryPredicate &&compare) -> void |
Sorts a range. More... | |
template<typename RandomAccessIt > | |
constexpr auto | kblib::sort (RandomAccessIt begin, RandomAccessIt end) -> void |
Variables | |
template<typename T > | |
constexpr bool | kblib::is_radix_sortable_v = is_radix_sortable<T>::value |
template<typename T > | |
constexpr bool | kblib::is_byte_v = false |
{WIP} Provides a fast and generic sorting interface.
Definition in file sort.h.