From 614ad48f7ff338c89338ac2f1a20622c89bea5c4 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 5 Jan 2023 23:54:23 +0800 Subject: [PATCH] feat: init type for AllCases --- klotski/all_cases.cc | 11 +++++++++++ klotski/all_cases.h | 9 ++++++++- klotski/main.cc | 9 +++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/klotski/all_cases.cc b/klotski/all_cases.cc index 238ae52..b8efe7c 100644 --- a/klotski/all_cases.cc +++ b/klotski/all_cases.cc @@ -107,6 +107,17 @@ void AllCases::find_all_cases() { // find all valid cases } } +AllCases::AllCases(enum InitType init) { + switch (init) { + case InitType::WITH_ALL_CASES: + get_all_cases(); + case InitType::WITH_BASIC_RANGES: + get_basic_ranges(); + case WITH_NOTHING: + break; + } +} + const std::vector* AllCases::get_basic_ranges() { if (basic_ranges.empty()) { build_basic_ranges(); // basic ranges initialize diff --git a/klotski/all_cases.h b/klotski/all_cases.h index 98084fc..1c45259 100644 --- a/klotski/all_cases.h +++ b/klotski/all_cases.h @@ -5,7 +5,14 @@ class AllCases { public: -// AllCases() {} + enum InitType { + WITH_NOTHING, + WITH_BASIC_RANGES, + WITH_ALL_CASES, + }; + + explicit AllCases(enum InitType init); + AllCases():AllCases(InitType::WITH_NOTHING) {}; const std::vector* get_basic_ranges(); const std::vector (*get_all_cases())[16]; diff --git a/klotski/main.cc b/klotski/main.cc index 04f1d51..ad78994 100644 --- a/klotski/main.cc +++ b/klotski/main.cc @@ -3,10 +3,15 @@ int main() { - auto a = AllCases(); +// auto a = AllCases(); +// auto a = AllCases(AllCases::InitType::WITH_NOTHING); +// auto a = AllCases(AllCases::InitType::WITH_BASIC_RANGES); + auto a = AllCases(AllCases::InitType::WITH_ALL_CASES); - std::cout << "basic range size: " << a.get_basic_ranges()->size() << std::endl; + std::cout << "start get basic ranges" << std::endl; + std::cout << "basic range: " << a.get_basic_ranges()->size() << std::endl; + std::cout << "start get all cases" << std::endl; for (const auto &temp : *a.get_all_cases()) { std::cout << temp.size() << std::endl; }