#pragma once #include #include #include #include #include #include "core.h" #include "raw_code.h" const uint32_t FC_MAP_RESERVE = 65536; /// FastCal not found -> return invalid raw code const RawCode FC_NOT_FOUND = RawCode::unsafe_create(0); class FastCal { public: typedef std::function match_t; /// setting root code void set_root(const RawCode &code); explicit FastCal(const RawCode &code); /// backtrack functions int step_num(const RawCode &code); std::vector backtrack(const RawCode &code); /// BFS search functions void build(); RawCode solve(); std::vector furthest(); std::vector solve_multi(); RawCode target(const match_t &match); std::vector target_multi(const match_t &match); /// static BFS search functions static std::vector resolve(const RawCode &start); static std::vector> to_furthest(const RawCode &start); static std::vector> resolve_multi(const RawCode &start); static std::vector search(const RawCode &start, const match_t &match); static std::vector> search_multi(const RawCode &start, const match_t &match); private: struct fast_cal_t { uint64_t code; uint64_t mask; fast_cal_t *last; }; uint64_t root; std::queue cache; std::unordered_map cases; inline Core init(uint64_t code); void new_case(uint64_t code, uint64_t mask); };