diff --git a/src/analyse/backtrack.cc b/src/analyse/backtrack.cc index 5b6c133..3008add 100644 --- a/src/analyse/backtrack.cc +++ b/src/analyse/backtrack.cc @@ -7,66 +7,33 @@ // TODO: using const RawCode& instead of uint64_t -struct backtrack_hash { -// template -// std::size_t operator()(const std::pair &v) const { -// return std::hash()(v.size()); -// } - - std::size_t operator()(const Analyse::backtrack_t &b) const { - std::cout << "hash -> " << b.code << std::endl; - - auto hash_ret = std::hash()(b.code); - - std::cout << "hash ret -> " << hash_ret << std::endl; - - return b.code; - } +namespace std { + template<> + struct hash { + std::size_t operator()(const Analyse::backtrack_t &b) const { +// std::cout << "get hash: " << b.code << std::endl; + return std::hash()(b.code); + } + }; -}; + template<> + struct equal_to { + bool operator()(const Analyse::backtrack_t &b1, const Analyse::backtrack_t &b2) const { +// std::cout << "get eq: " << b1.code << " ? " << b2.code << std::endl; + return b1.code == b2.code; + } + }; +} void Analyse::backtrack_demo(uint64_t code) { -// std::cout << RawCode(code) << std::endl; - // TODO: confirm code exist std::cout << cases[code].step << std::endl; // std::vector> dat; - auto b_hash = [](const backtrack_t &b) { - auto hash_dat = std::hash()(b.code); - std::cout << "get hash: " << b.code << " -> " << hash_dat << std::endl; - return hash_dat; - }; - - auto b_eq = [](const backtrack_t &b1, const backtrack_t &b2) { - std::cout << "get eq: " << b1.code << " ? " << b2.code << std::endl; - return b1.code == b2.code; - }; - - std::unordered_set test(0, b_hash, b_eq); + std::unordered_set test; -// test.emplace(backtrack_t { -// .code = 123, -// .layer_num = 0, -// .last = std::list{}, -// .next = std::list{}, -// }); -// -// test.emplace(backtrack_t { -// .code = 233, -// .layer_num = 1, -// .last = std::list{}, -// .next = std::list{}, -// }); -// -// test.emplace(backtrack_t { -// .code = 343, -// .layer_num = 2, -// .last = std::list{}, -// .next = std::list{}, -// }); for (uint32_t i = 0; i < 20; ++i) { test.emplace(backtrack_t { diff --git a/src/fast_cal/fast_cal.h b/src/fast_cal/fast_cal.h index 955b264..314416c 100644 --- a/src/fast_cal/fast_cal.h +++ b/src/fast_cal/fast_cal.h @@ -8,6 +8,7 @@ #include "core.h" #include "raw_code.h" +// TODO: using prime number const uint32_t FC_MAP_RESERVE = 65536 * 8; /// FastCal not found -> return invalid raw code