forked from mirror/toddcox-faster
Compare commits
2 Commits
path-conte
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
265de59917 | ||
|
|
16c9d7d62f |
@@ -29,6 +29,25 @@ namespace tc {
|
||||
[[nodiscard]] Action get(int to_idx) const;
|
||||
|
||||
void put(int from_idx, int gen, int to_idx);
|
||||
|
||||
template<class C, class T, class E>
|
||||
void walk(
|
||||
C& res,
|
||||
T start,
|
||||
std::vector<E> gens,
|
||||
std::function<T(const T &, const E &)> 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<class T, class E>
|
||||
[[nodiscard]] std::vector<T> walk(
|
||||
@@ -36,14 +55,15 @@ namespace tc {
|
||||
std::vector<E> gens,
|
||||
std::function<T(const T &, const E &)> op
|
||||
) const {
|
||||
std::vector<T> res(size());
|
||||
res[0] = start;
|
||||
std::vector<T> res;
|
||||
res.reserve(size());
|
||||
res.push_back(start);
|
||||
|
||||
for (int i = 1; i < res.size(); ++i) {
|
||||
for (int i = 1; i < size(); ++i) {
|
||||
auto &action = path[i];
|
||||
auto &from = res[action.from_idx];
|
||||
auto &val = gens[action.gen];
|
||||
res[i] = op(from, val);
|
||||
res.push_back(op(from, val));
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -54,10 +74,11 @@ namespace tc {
|
||||
T start,
|
||||
std::function<T(const T &, const int &)> op
|
||||
) const {
|
||||
std::vector<T> res(size());
|
||||
res[0] = start;
|
||||
std::vector<T> res;
|
||||
res.reserve(size());
|
||||
res.push_back(start);
|
||||
|
||||
for (int i = 1; i < res.size(); ++i) {
|
||||
for (int i = 1; i < size(); ++i) {
|
||||
auto &action = path[i];
|
||||
auto &from = res[action.from_idx];
|
||||
auto &val = action.gen;
|
||||
@@ -108,7 +129,7 @@ namespace tc {
|
||||
struct SubGroup;
|
||||
|
||||
struct Group {
|
||||
const int ngens;
|
||||
int ngens;
|
||||
std::vector<std::vector<int>> _mults;
|
||||
std::string name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user