1 #ifndef __CTSORT_CXX14_HPP_INCLUDED__
2 #define __CTSORT_CXX14_HPP_INCLUDED__
38 #include <type_traits>
48 template<
typename _Traits,
typename _AllowDuplicates>
60 std::numeric_limits<hash_type>::is_integer ||
65 template<
typename _Init>
66 static constexpr
auto sort(_Init&&
init) noexcept
71 template<
bool _SortByValues,
typename _Init>
72 static constexpr
auto sort(std::integral_constant<bool, _SortByValues> _Tag, _Init&&
init) noexcept
77 template<
typename _Init>
82 return std::make_pair(real_size, indices);
89 template<
typename _Input>
92 return typename sort_traits::hashed_key_type::hash_compare{}(
93 sort_traits::get_init_hash(
input[l]),
94 sort_traits::get_init_hash(
input[
r])
105 return std::make_tuple(indices.first, values, hashes);
113 return std::make_pair(indices.first, values);
116 template<
typename _Indices>
122 indices[
prev] = indices[tail];
124 indices[
head] = current;
126 template<
typename _Indices,
typename _Input,
typename _Pred>
135 const size_type _UMid = _UFirst + _Count2;
138 _UFirst = (_UMid + 1);
139 _Count -= _Count2 + 1;
149 template<
typename _Indices,
typename _Input,
typename _Pred>
158 const size_type _UMid = _UFirst + _Count2;
165 _UFirst = (_UMid + 1);
166 _Count -= _Count2 + 1;
173 template<
typename _Indices,
typename _Input>
188 while (current !=
size)
202 need_to_move = (fit == 0) || pred(
input,
result[fit-1], current);
215 while (++current !=
size)
223 template<
typename _Input,
typename _Indices,
size_type... I>
224 static constexpr
auto construct_hashes(
const _Input&
input,
const _Indices& indices, std::index_sequence<I...>) noexcept
228 return { sort_traits::get_init_hash(
input[indices.second[I < real_size ? I : real_size - 1]]) ...};
231 template<
typename _Input,
typename _Indices,
size_type... I>
232 static constexpr
auto construct_values(
const _Input&
input,
const _Indices& indices, std::index_sequence<I...>) noexcept
235 auto real_size = indices.first;
236 return { sort_traits::construct(
input[indices.second[I < real_size ? I : real_size - 1]]) ...};
static constexpr void insert_down(_Indices &indices, size_type head, size_type tail, size_type current)
static constexpr auto make_indices(_Init &&input) noexcept
static constexpr auto x_sort(tag_SortByHashes, const _Init &init) noexcept
static constexpr size_type const_lower_bound(_Pred pred, const _Indices &indices, const _Input &input, size_type size, size_type value)
static constexpr size_type insert_sort_indices(_Indices &result, const _Input &input)
static constexpr auto sort(_Init &&init) noexcept
static constexpr auto construct_values(const _Input &input, const _Indices &indices, std::index_sequence< I... >) noexcept -> const_array< value_type, sizeof...(I)>
typename sort_traits::init_type init_type
static constexpr auto x_sort(tag_SortByValues, const _Init &init) noexcept
static constexpr auto construct_hashes(const _Input &input, const _Indices &indices, std::index_sequence< I... >) noexcept -> const_array< hash_type, sizeof...(I)>
static constexpr size_type const_upper_bound(_Pred pred, const _Indices &indices, const _Input &input, size_type size, size_type value)
typename sort_traits::value_type value_type
static constexpr bool remove_duplicates
static constexpr bool can_index
typename sort_traits::hash_type hash_type
static constexpr auto sort(std::integral_constant< bool, _SortByValues > _Tag, _Init &&init) noexcept
std::integral_constant< bool, can_index > tag_can_index
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
std::false_type tag_SortByValues
std::true_type tag_SortByHashes
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
constexpr bool operator()(const _Input &input, size_t l, size_t r) const