mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 03:52:48 -05:00
std::queue facts is faster
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
#include <tc/core.hpp>
|
#include <tc/core.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <queue>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace tc {
|
namespace tc {
|
||||||
SubGroup Group::subgroup(const std::vector<int> &gens) const {
|
SubGroup Group::subgroup(const std::vector<int> &gens) const {
|
||||||
@@ -97,8 +99,8 @@ namespace tc {
|
|||||||
rel_tables.add_row();
|
rel_tables.add_row();
|
||||||
|
|
||||||
// queue of products that can be determined by the new coset
|
// queue of products that can be determined by the new coset
|
||||||
std::vector<int> facts;
|
std::queue<int> facts;
|
||||||
facts.push_back(idx);
|
facts.push(idx);
|
||||||
|
|
||||||
// todo unrolled linked list interval
|
// todo unrolled linked list interval
|
||||||
// coset = idx / ngens;
|
// coset = idx / ngens;
|
||||||
@@ -106,16 +108,11 @@ namespace tc {
|
|||||||
// rel_tables.del_rows_to(coset);
|
// rel_tables.del_rows_to(coset);
|
||||||
|
|
||||||
while (!facts.empty()) {
|
while (!facts.empty()) {
|
||||||
// todo heap
|
fact_idx = facts.front();
|
||||||
std::sort(facts.begin(), facts.end(), std::greater<>());
|
facts.pop();
|
||||||
fact_idx = facts.back();
|
|
||||||
facts.pop_back();
|
|
||||||
|
|
||||||
// skip if this product was already determined
|
// skip if this product was already determined
|
||||||
// todo try to avoid these duplications
|
if (cosets.get(fact_idx) != -1)continue;
|
||||||
if (cosets.get(fact_idx) != -1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cosets.put(fact_idx, target);
|
cosets.put(fact_idx, target);
|
||||||
|
|
||||||
@@ -149,10 +146,10 @@ namespace tc {
|
|||||||
lst = *(trow.lst_ptr);
|
lst = *(trow.lst_ptr);
|
||||||
delete trow.lst_ptr;
|
delete trow.lst_ptr;
|
||||||
gen_ = rel.gens[(int) (rel.gens[0] == gen)];
|
gen_ = rel.gens[(int) (rel.gens[0] == gen)];
|
||||||
facts.push_back(lst * ngens + gen_);
|
facts.push(lst * ngens + gen_);
|
||||||
} else if (trow.gnr == -rel.mult) {
|
} else if (trow.gnr == -rel.mult) {
|
||||||
gen_ = rel.gens[rel.gens[0] == gen];
|
gen_ = rel.gens[rel.gens[0] == gen];
|
||||||
facts.push_back(target * ngens + gen_);
|
facts.push(target * ngens + gen_);
|
||||||
} else if (trow.gnr == rel.mult - 1) {
|
} else if (trow.gnr == rel.mult - 1) {
|
||||||
*(trow.lst_ptr) = target;
|
*(trow.lst_ptr) = target;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user