| 18 | namespace enc { |
| 19 | template <typename... Strs> |
| 20 | auto MakeStrArrayImpl(Strs&&... strs) { |
| 21 | std::vector<std::string> names{strs...}; |
| 22 | std::vector<std::int8_t> values; |
| 23 | std::vector<std::int32_t> offsets{0}; |
| 24 | |
| 25 | for (const auto& name : names) { |
| 26 | for (char c : name) { |
| 27 | values.push_back(c); |
| 28 | } |
| 29 | offsets.push_back(name.size()); |
| 30 | } |
| 31 | std::partial_sum(offsets.cbegin(), offsets.cend(), offsets.begin()); |
| 32 | return xgboost::cpu_impl::CatStrArray{offsets, values}; |
| 33 | } |
| 34 | } // namespace enc |
| 35 | |
| 36 | namespace enc::cpu_impl { |