Browse Source

update: ShortCode class init

legacy
Dnomd343 2 years ago
parent
commit
c322c34ba7
  1. 12
      klotski/main.cc
  2. 4
      klotski/short_code.cc
  3. 3
      klotski/short_code.h

12
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;
}

4
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);
}

3
klotski/short_code.h

@ -14,6 +14,9 @@ public:
std::vector<uint64_t> all_cases_list; // short_code -> common_code
std::unordered_map<uint64_t, uint32_t> 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);

Loading…
Cancel
Save