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

Function RunLengthEncode

src/common/numeric.h:33–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 */
32template <typename Iter, typename Idx>
33void RunLengthEncode(Iter begin, Iter end, std::vector<Idx>* p_out) {
34 auto& out = *p_out;
35 out = std::vector<Idx>{0};
36 size_t n = std::distance(begin, end);
37 for (size_t i = 1; i < n; ++i) {
38 if (begin[i] != begin[i - 1]) {
39 out.push_back(i);
40 }
41 }
42 if (out.back() != n) {
43 out.push_back(n);
44 }
45}
46
47/**
48 * @brief Variant of std::partial_sum, out_it should point to a container that has n + 1

Callers 3

EncodeTreeLeafHostFunction · 0.85
SetInfoFromHostMethod · 0.85
TestLeafPartitionFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestLeafPartitionFunction · 0.68