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

Function ArgSort

src/common/algorithm.h:80–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78template <typename Idx, typename Iter, typename V = typename std::iterator_traits<Iter>::value_type,
79 typename Comp = std::less<V>>
80std::vector<Idx> ArgSort(Context const *ctx, Iter begin, Iter end, Comp comp = std::less<V>{}) {
81 auto n = std::distance(begin, end);
82 std::vector<Idx> result(n);
83 Iota(ctx, result.begin(), result.end(), 0);
84 auto op = [&](Idx const &l, Idx const &r) { return comp(begin[l], begin[r]); };
85 StableSort(ctx, result.begin(), result.end(), op);
86 return result;
87}
88} // namespace common
89} // namespace xgboost
90

Callers

nothing calls this directly

Calls 4

IotaFunction · 0.85
StableSortFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected