|
@ -2,13 +2,11 @@ |
|
|
#include "fast_cal.h" |
|
|
#include "fast_cal.h" |
|
|
|
|
|
|
|
|
Core FastCal::init(uint64_t code) { // initialize process
|
|
|
Core FastCal::init(uint64_t code) { // initialize process
|
|
|
/// clear working data
|
|
|
/// reset working data
|
|
|
cases.clear(); |
|
|
cases.clear(); |
|
|
|
|
|
cases.reserve(FC_MAP_RESERVE); // hashmap pre-reserve
|
|
|
std::queue<fast_cal_t*>{}.swap(cache); |
|
|
std::queue<fast_cal_t*>{}.swap(cache); |
|
|
|
|
|
|
|
|
// TODO: test the speed without hashmap reserve
|
|
|
|
|
|
cases.reserve(65536); |
|
|
|
|
|
|
|
|
|
|
|
/// insert root node
|
|
|
/// insert root node
|
|
|
cache.emplace(&cases.emplace(code, fast_cal_t { |
|
|
cache.emplace(&cases.emplace(code, fast_cal_t { |
|
|
.code = code, |
|
|
.code = code, |
|
@ -39,7 +37,7 @@ void FastCal::new_case(uint64_t code, uint64_t mask) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// found first matched target
|
|
|
/// found first matched target
|
|
|
RawCode FastCal::target(RawCode code, const check_t &match) { |
|
|
RawCode FastCal::target(RawCode code, const match_t &match) { |
|
|
auto core = init((uint64_t)code); |
|
|
auto core = init((uint64_t)code); |
|
|
/// start bfs search
|
|
|
/// start bfs search
|
|
|
while (!cache.empty()) { |
|
|
while (!cache.empty()) { |
|
@ -53,7 +51,7 @@ RawCode FastCal::target(RawCode code, const check_t &match) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// found multi-targets matched in first same layer
|
|
|
/// found multi-targets matched in first same layer
|
|
|
std::vector<RawCode> FastCal::target_multi(RawCode code, const check_t &match) { |
|
|
std::vector<RawCode> FastCal::target_multi(RawCode code, const match_t &match) { |
|
|
auto core = init((uint64_t)code); |
|
|
auto core = init((uint64_t)code); |
|
|
auto layer_end = cache.back(); |
|
|
auto layer_end = cache.back(); |
|
|
std::vector<RawCode> matched; // matched list
|
|
|
std::vector<RawCode> matched; // matched list
|
|
|