30 template <
class... Args>
32 concatenate(
const std::vector<Args...>& lhs,
const std::vector<Args...>& rhs)
34 std::vector<Args...> conc = lhs;
35 std::copy(rhs.begin(), rhs.end(), std::back_inserter(conc));
40 template <
class KeyT,
class ValueT>
41 std::map<KeyT, ValueT>
44 const size_t size =
std::min(lhs.size(), rhs.size());
46 std::map<KeyT, ValueT> map;
47 for (
size_t i = 0; i < size; ++i)
49 map.emplace(lhs[i], rhs[i]);
55 template <
class KeyT,
class ValueT>
57 multi_at(
const std::map<KeyT, ValueT>& map,
58 const std::vector<KeyT>& keys,
59 bool skipMissing =
false)
61 std::vector<ValueT>
values;
62 values.reserve(keys.size());
64 for (
const KeyT& key : keys)
68 if (
auto it = map.find(key); it != map.end())
70 values.push_back(it->second);
76 values.push_back(map.at(key));
83 template <
class... Args>
85 slice(
const std::vector<Args...>& vector,
87 std::optional<size_t> end = std::nullopt)
89 std::vector<Args...> result;
90 auto beginIt = vector.begin() + start;
91 auto endIt = end ? vector.begin() + *end : vector.end();
92 std::copy(beginIt, endIt, std::back_inserter(result));