MCPcopy Create free account
hub / github.com/dmlc/xgboost / ArgSort

Function ArgSort

src/encoder/ordinal.h:208–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206namespace cpu_impl {
207template <typename InIt, typename OutIt, typename Comp>
208void ArgSort(InIt in_first, InIt in_last, OutIt out_first, Comp comp = std::less{}) {
209 auto n = std::distance(in_first, in_last);
210 using Idx = typename std::iterator_traits<OutIt>::value_type;
211
212 auto out_last = out_first + n;
213 std::iota(out_first, out_last, 0);
214 auto op = [&](Idx const &l, Idx const &r) {
215 return comp(in_first[l], in_first[r]);
216 };
217 std::stable_sort(out_first, out_last, op);
218}
219
220[[nodiscard]] inline std::int32_t SearchSorted(CatStrArrayView haystack,
221 Span<std::int32_t const> ref_sorted_idx,

Callers 1

SortNamesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected