|
|
@ -6,13 +6,25 @@ |
|
|
|
|
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
void FastCal::fast_cal(uint64_t code) { |
|
|
|
void FastCal::new_case(uint64_t code, uint64_t mask) { // callback function for new case
|
|
|
|
auto current = cases.find(code); |
|
|
|
if (current != cases.end()) { // find existed case
|
|
|
|
current->second.mask |= mask; // update mask info
|
|
|
|
return; |
|
|
|
} |
|
|
|
cases[code] = fast_cal_t { // insert into cases map
|
|
|
|
.code = code, |
|
|
|
.mask = mask, |
|
|
|
.last = cache.front(), // parent case
|
|
|
|
}; |
|
|
|
cache.emplace(&cases[code]); // add in working queue
|
|
|
|
} |
|
|
|
|
|
|
|
// std::cout << RawCode(code).dump_case() << std::endl;
|
|
|
|
void FastCal::fast_cal(uint64_t code) { |
|
|
|
|
|
|
|
auto core = Core( |
|
|
|
[this](auto &&code, auto &&mask) { // lambda as function pointer
|
|
|
|
add_new_case(std::forward<decltype(code)>(code), std::forward<decltype(mask)>(mask)); |
|
|
|
new_case(std::forward<decltype(code)>(code), std::forward<decltype(mask)>(mask)); |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
@ -47,22 +59,3 @@ void FastCal::fast_cal(uint64_t code) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void FastCal::add_new_case(uint64_t code, uint64_t mask) { |
|
|
|
|
|
|
|
auto exist_case = cases.find(code); |
|
|
|
if (exist_case != cases.end()) { // find existed case
|
|
|
|
|
|
|
|
exist_case->second.mask |= mask; // mask update
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cases[code] = fast_cal_t { |
|
|
|
.code = code, |
|
|
|
.mask = mask, |
|
|
|
.last = cache.front(), |
|
|
|
}; |
|
|
|
cache.emplace(&cases[code]); |
|
|
|
|
|
|
|
} |
|
|
|