|
@ -7,66 +7,33 @@ |
|
|
|
|
|
|
|
|
// TODO: using const RawCode& instead of uint64_t
|
|
|
// TODO: using const RawCode& instead of uint64_t
|
|
|
|
|
|
|
|
|
struct backtrack_hash { |
|
|
namespace std { |
|
|
// template <class T1, class T2>
|
|
|
template<> |
|
|
// std::size_t operator()(const std::pair<T1, T2> &v) const {
|
|
|
struct hash<Analyse::backtrack_t> { |
|
|
// return std::hash<T1>()(v.size());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
std::size_t operator()(const Analyse::backtrack_t &b) const { |
|
|
std::size_t operator()(const Analyse::backtrack_t &b) const { |
|
|
std::cout << "hash -> " << b.code << std::endl; |
|
|
// std::cout << "get hash: " << b.code << std::endl;
|
|
|
|
|
|
return std::hash<uint64_t>()(b.code); |
|
|
auto hash_ret = std::hash<uint64_t>()(b.code); |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "hash ret -> " << hash_ret << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
return b.code; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
struct equal_to<Analyse::backtrack_t> { |
|
|
|
|
|
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) { |
|
|
void Analyse::backtrack_demo(uint64_t code) { |
|
|
|
|
|
|
|
|
// std::cout << RawCode(code) << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: confirm code exist
|
|
|
// TODO: confirm code exist
|
|
|
std::cout << cases[code].step << std::endl; |
|
|
std::cout << cases[code].step << std::endl; |
|
|
|
|
|
|
|
|
// std::vector<std::unordered_set<backtrack_t>> dat;
|
|
|
// std::vector<std::unordered_set<backtrack_t>> dat;
|
|
|
|
|
|
|
|
|
auto b_hash = [](const backtrack_t &b) { |
|
|
std::unordered_set<backtrack_t> test; |
|
|
auto hash_dat = std::hash<uint64_t>()(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<backtrack_t, decltype(b_hash), decltype(b_eq)> test(0, b_hash, b_eq); |
|
|
|
|
|
|
|
|
|
|
|
// test.emplace(backtrack_t {
|
|
|
|
|
|
// .code = 123,
|
|
|
|
|
|
// .layer_num = 0,
|
|
|
|
|
|
// .last = std::list<backtrack_t*>{},
|
|
|
|
|
|
// .next = std::list<backtrack_t*>{},
|
|
|
|
|
|
// });
|
|
|
|
|
|
//
|
|
|
|
|
|
// test.emplace(backtrack_t {
|
|
|
|
|
|
// .code = 233,
|
|
|
|
|
|
// .layer_num = 1,
|
|
|
|
|
|
// .last = std::list<backtrack_t*>{},
|
|
|
|
|
|
// .next = std::list<backtrack_t*>{},
|
|
|
|
|
|
// });
|
|
|
|
|
|
//
|
|
|
|
|
|
// test.emplace(backtrack_t {
|
|
|
|
|
|
// .code = 343,
|
|
|
|
|
|
// .layer_num = 2,
|
|
|
|
|
|
// .last = std::list<backtrack_t*>{},
|
|
|
|
|
|
// .next = std::list<backtrack_t*>{},
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < 20; ++i) { |
|
|
for (uint32_t i = 0; i < 20; ++i) { |
|
|
test.emplace(backtrack_t { |
|
|
test.emplace(backtrack_t { |
|
|