aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorthecharlesblake2018-01-12 16:31:16 +0000
committerthecharlesblake2018-01-12 16:31:16 +0000
commitf12e2936fda51eb59016dd316ff9c73fba621fa2 (patch)
tree506625585be68761fca948b96747f948d292bb78 /src
parentMerge pull request #29 from thecharlesblake/refactor-improve-debug (diff)
downloadmetasol-f12e2936fda51eb59016dd316ff9c73fba621fa2.tar.gz
metasol-f12e2936fda51eb59016dd316ff9c73fba621fa2.zip

Add basic global_cache interface

Diffstat (limited to 'src')
-rw-r--r--src/main/game/global_cache.cpp16
-rw-r--r--src/main/game/global_cache.h29
2 files changed, 45 insertions, 0 deletions
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp
new file mode 100644
index 0000000..cc95b3b
--- /dev/null
+++ b/src/main/game/global_cache.cpp
@@ -0,0 +1,16 @@
+//
+// Created by thecharlesblake on 1/10/18.
+//
+
+#include "global_cache.h"
+
+
+global_cache::global_cache(const sol_rules&) {}
+
+bool global_cache::insert(const std::vector<pile>& pile_vec) {
+ return u_set.insert(pile_vec).second;
+}
+
+bool global_cache::contains(const std::vector<pile>& pile_vec) {
+ return u_set.count(pile_vec) > 0;
+}
diff --git a/src/main/game/global_cache.h b/src/main/game/global_cache.h
new file mode 100644
index 0000000..b35acc6
--- /dev/null
+++ b/src/main/game/global_cache.h
@@ -0,0 +1,29 @@
+//
+// Created by thecharlesblake on 1/10/18.
+//
+
+#ifndef SOLVITAIRE_GLOBAL_CACHE_H
+#define SOLVITAIRE_GLOBAL_CACHE_H
+
+#include <vector>
+#include <unordered_set>
+
+#include "../game/game_state.h"
+#include "../game/sol_rules.h"
+
+class global_cache {
+public:
+ explicit global_cache(const sol_rules&);
+
+ bool insert(const std::vector<pile>&);
+ bool contains(const std::vector<pile>&);
+
+private:
+ std::unordered_set<
+ std::vector<pile>,
+ boost::hash<std::vector<pile>>
+ > u_set;
+};
+
+
+#endif //SOLVITAIRE_GLOBAL_CACHE_H