diff --git a/include/tc/core.hpp b/include/tc/core.hpp index d69f1b0..8594adc 100644 --- a/include/tc/core.hpp +++ b/include/tc/core.hpp @@ -29,6 +29,25 @@ namespace tc { [[nodiscard]] Action get(int to_idx) const; void put(int from_idx, int gen, int to_idx); + + template + void walk( + C& res, + T start, + std::vector gens, + std::function op + ) const { + size_t s = size(); + res.reserve(s); + res.push_back(start); + + for (int i = 1; i < s; ++i) { + auto &action = path[i]; + auto &from = res.get(action.from_idx); + auto &val = gens[action.gen]; + res.push_back(op(from,val)); + } + } template [[nodiscard]] std::vector walk(