libhatchet
Loading...
Searching...
No Matches
hxsort.hpp File Reference

Go to the source code of this file.

Functions

template<typename iterator_t_, typename value_t_, typename less_t_>
HX_NS_BEGIN_ constexpr iterator_t_ hxlower_bound (iterator_t_ begin_, iterator_t_ end_, const value_t_ &value_, const less_t_ &less_)
template<typename iterator_t_, typename value_t_>
constexpr iterator_t_ hxlower_bound (iterator_t_ begin_, iterator_t_ end_, const value_t_ &value_)
template<typename iterator_t_, typename value_t_, typename less_t_>
constexpr iterator_t_ hxupper_bound (iterator_t_ begin_, iterator_t_ end_, const value_t_ &value_, const less_t_ &less_)
template<typename iterator_t_, typename value_t_>
constexpr iterator_t_ hxupper_bound (iterator_t_ begin_, iterator_t_ end_, const value_t_ &value_)
template<typename iterator_t_, typename value_t_, typename less_t_>
constexpr iterator_t_ hxbinary_search (iterator_t_ begin_, iterator_t_ end_, const value_t_ &value_, const less_t_ &less_)
template<typename iterator_t_, typename value_t_>
constexpr iterator_t_ hxbinary_search (iterator_t_ begin_, iterator_t_ end_, const value_t_ &value_)
template<typename iterator_t_, typename less_t_>
constexpr void hxinsertion_sort (iterator_t_ begin_, iterator_t_ end_, const less_t_ &less_)
template<typename iterator_t_>
constexpr void hxinsertion_sort (iterator_t_ begin_, iterator_t_ end_)
template<typename iterator_t_, typename less_t_>
constexpr void hxheapsort (iterator_t_ begin_, iterator_t_ end_, const less_t_ &less_)
template<typename iterator_t_>
constexpr void hxheapsort (iterator_t_ begin_, iterator_t_ end_)
template<typename iterator_t_, typename less_t_>
constexpr void hxsort (iterator_t_ begin_, iterator_t_ end_, const less_t_ &less_)
template<typename iterator_t_>
constexpr void hxsort (iterator_t_ begin_, iterator_t_ end_)

Detailed Description

Standard sorting utilities.

For scalar key sorting see hxradix_sort.hpp. Includes support for callables when defining custom key operations. Otherwise T::operator<(const T&) and T::operator==(const T&) are used. The other relational operators are not used.

Function Documentation

◆ hxbinary_search() [1/2]

template<typename iterator_t_, typename value_t_>
iterator_t_ hxbinary_search ( iterator_t_ begin_,
iterator_t_ end_,
const value_t_ & value_ )
inlineconstexpr

hxbinary_search (specialization) - An overload of hxbinary_search that searches for value in the range [begin, end) using hxkey_less.

Requires a random-iterator.

◆ hxbinary_search() [2/2]

template<typename iterator_t_, typename value_t_, typename less_t_>
iterator_t_ hxbinary_search ( iterator_t_ begin_,
iterator_t_ end_,
const value_t_ & value_,
const less_t_ & less_ )
inlineconstexpr

hxbinary_search - Performs a binary search for value in the range [first, last).

Returns end if the value is not found. Unsorted data will lead to errors. The first of non-unique values is returned. The less callable returns true if the first argument is ordered before (i.e., is less than) the second. Requires a random-iterator.

◆ hxheapsort() [1/2]

template<typename iterator_t_>
void hxheapsort ( iterator_t_ begin_,
iterator_t_ end_ )
inlineconstexpr

hxheapsort (specialization) - An overload of hxheapsort over the range [begin, end) that uses hxkey_less.

Requires a random-iterator.

◆ hxheapsort() [2/2]

template<typename iterator_t_, typename less_t_>
void hxheapsort ( iterator_t_ begin_,
iterator_t_ end_,
const less_t_ & less_ )
inlineconstexpr

hxheapsort - Sorts the elements in the range [begin, end) using the heapsort algorithm.

The less callable defines the less-than ordering relationship. Requires a random-iterator.

◆ hxinsertion_sort() [1/2]

template<typename iterator_t_>
void hxinsertion_sort ( iterator_t_ begin_,
iterator_t_ end_ )
inlineconstexpr

hxinsertion_sort (specialization) - An overload of hxinsertion_sort over the range [begin, end) that uses hxkey_less.

Requires a random-iterator.

◆ hxinsertion_sort() [2/2]

template<typename iterator_t_, typename less_t_>
void hxinsertion_sort ( iterator_t_ begin_,
iterator_t_ end_,
const less_t_ & less_ )
inlineconstexpr

hxinsertion_sort - Sorts the elements in the range [begin, end) in comparison order using the insertion sort algorithm.

The end parameter points just past the end of the array. Exception handling during operation is undefined. Declare your copy constructor and assignment operator noexcept or turn off exceptions. All of T::T(&&), T::~T() and T::operator=(T&&) are used. The less callable defines the less-than ordering relationship. Requires a random-iterator.

◆ hxlower_bound() [1/2]

template<typename iterator_t_, typename value_t_>
iterator_t_ hxlower_bound ( iterator_t_ begin_,
iterator_t_ end_,
const value_t_ & value_ )
inlineconstexpr

hxlower_bound (specialization) - An overload of hxlower_bound over the range [begin, end) that uses hxkey_less.

Requires a random-iterator.

◆ hxlower_bound() [2/2]

template<typename iterator_t_, typename value_t_, typename less_t_>
HX_NS_BEGIN_ constexpr iterator_t_ hxlower_bound ( iterator_t_ begin_,
iterator_t_ end_,
const value_t_ & value_,
const less_t_ & less_ )
inlineconstexpr

hxlower_bound - Returns the first position in the sorted range [begin, end) where value could be inserted without violating the ordering.

Returns end if no element is ordered after or equivalent to value. Unsorted data will lead to errors. The less callable returns true if the first argument is ordered before (i.e., is less than) the second. Requires a random-iterator.

◆ hxsort() [1/2]

template<typename iterator_t_>
void hxsort ( iterator_t_ begin_,
iterator_t_ end_ )
inlineconstexpr

hxsort (specialization) - An overload of hxsort over the range [begin, end) that uses hxkey_less.

This version is intended for sorting large numbers of small objects. Requires a random-iterator.

◆ hxsort() [2/2]

template<typename iterator_t_, typename less_t_>
void hxsort ( iterator_t_ begin_,
iterator_t_ end_,
const less_t_ & less_ )
inlineconstexpr

hxsort - A general purpose sort routine using T::T(&&), T::~T(), T::operator=(&&), the hxswap overloads and a less callable which defaults to hxkey_less.

Sorts the range [begin, end). This version is intended for sorting large numbers of small objects. Requires a random-iterator.

◆ hxupper_bound() [1/2]

template<typename iterator_t_, typename value_t_>
iterator_t_ hxupper_bound ( iterator_t_ begin_,
iterator_t_ end_,
const value_t_ & value_ )
inlineconstexpr

hxupper_bound (specialization) - An overload of hxupper_bound over the range [begin, end) that uses hxkey_less.

Requires a random-iterator.

◆ hxupper_bound() [2/2]

template<typename iterator_t_, typename value_t_, typename less_t_>
iterator_t_ hxupper_bound ( iterator_t_ begin_,
iterator_t_ end_,
const value_t_ & value_,
const less_t_ & less_ )
inlineconstexpr

hxupper_bound - Returns the first position in the sorted range [begin, end) whose element is ordered after value.

Returns end if no such element exists. Unsorted data will lead to errors. The less callable returns true if the first argument is ordered before (i.e., is less than) the second. Requires a random-iterator.