From c322c34ba7c91581a0919240c0f6fbb776c8de2f Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Fri, 6 Jan 2023 01:56:02 +0800 Subject: [PATCH] update: ShortCode class init --- klotski/main.cc | 12 +++++++----- klotski/short_code.cc | 4 ++++ klotski/short_code.h | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/klotski/main.cc b/klotski/main.cc index a9a2c8d..511a124 100644 --- a/klotski/main.cc +++ b/klotski/main.cc @@ -17,17 +17,19 @@ int main() { // std::cout << temp.size() << std::endl; // } - auto s = ShortCode(); +// auto s = ShortCode(); +// auto s = ShortCode(ShortCode::Mode::NORMAL); + auto s = ShortCode(ShortCode::Mode::FAST); // s.speed_up(ShortCode::Mode::FAST); -// std::cout << s.all_cases_list.size() << std::endl; -// std::cout << s.all_cases_dict.size() << std::endl; + std::cout << s.all_cases_list.size() << std::endl; + std::cout << s.all_cases_dict.size() << std::endl; // printf("%d\n", s.fast_encode(0x6EC0F8800)); // printf("%09lX\n", s.fast_decode(14323231)); - s.speed_up(ShortCode::Mode::NORMAL); - std::cout << s.basic_ranges.size() << std::endl; +// s.speed_up(ShortCode::Mode::NORMAL); +// std::cout << s.basic_ranges.size() << std::endl; return 0; } diff --git a/klotski/short_code.cc b/klotski/short_code.cc index 6e93d61..ecf1342 100644 --- a/klotski/short_code.cc +++ b/klotski/short_code.cc @@ -44,3 +44,7 @@ uint32_t ShortCode::fast_encode(uint64_t common_code) { // common_code -> short_ // TODO: ensure input common_code valid return all_cases_dict[common_code]; } + +ShortCode::ShortCode(ShortCode::Mode mode) { + speed_up(mode); +} diff --git a/klotski/short_code.h b/klotski/short_code.h index a6d0cf4..a253873 100644 --- a/klotski/short_code.h +++ b/klotski/short_code.h @@ -14,6 +14,9 @@ public: std::vector all_cases_list; // short_code -> common_code std::unordered_map all_cases_dict; // common_code -> short_code + ShortCode() = default; + explicit ShortCode(enum Mode mode); + void speed_up(enum Mode mode); // uint32_t zip_short_code(uint64_t code);