diff options
Diffstat (limited to 'src/main/game')
| -rw-r--r-- | src/main/game/global_cache.cpp | 8 | ||||
| -rw-r--r-- | src/main/game/global_cache.h | 1 | ||||
| -rw-r--r-- | src/main/game/pile.cpp | 7 | ||||
| -rw-r--r-- | src/main/game/pile.h | 2 |
4 files changed, 11 insertions, 7 deletions
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp index f55a72c..e881408 100644 --- a/src/main/game/global_cache.cpp +++ b/src/main/game/global_cache.cpp @@ -2,8 +2,12 @@ // Created by thecharlesblake on 1/10/18. // +#include <boost/functional/hash.hpp> + #include "global_cache.h" +using namespace std; +using namespace boost; typedef sol_rules::build_policy pol; @@ -40,3 +44,7 @@ size_t hash_value(card const& c) { auto raw_val = static_cast<unsigned char>(suit_val * 13 + c.get_rank()); return hasher(raw_val); } + +size_t hash_value(pile const& p) { + return hash_range(begin(p.pile_vec), end(p.pile_vec)); +} diff --git a/src/main/game/global_cache.h b/src/main/game/global_cache.h index a5c6768..26a73ef 100644 --- a/src/main/game/global_cache.h +++ b/src/main/game/global_cache.h @@ -21,6 +21,7 @@ public: friend std::size_t hash_value(card const&); private: static sol_rules rules; + std::unordered_set< std::vector<pile>, boost::hash<std::vector<pile>> diff --git a/src/main/game/pile.cpp b/src/main/game/pile.cpp index ad7b85e..ba7c1b9 100644 --- a/src/main/game/pile.cpp +++ b/src/main/game/pile.cpp @@ -5,12 +5,9 @@ #include <vector> #include <ostream> -#include <boost/functional/hash.hpp> - #include "pile.h" using namespace std; -using namespace boost; pile::pile(std::vector<card> pv) : pile_vec(pv) {} @@ -49,7 +46,3 @@ card pile::take() { bool operator==(const pile& a, const pile& b) { return a.pile_vec == b.pile_vec; } - -size_t hash_value(pile const& p) { - return hash_range(begin(p.pile_vec), end(p.pile_vec)); -} diff --git a/src/main/game/pile.h b/src/main/game/pile.h index fb7bc38..ab661ca 100644 --- a/src/main/game/pile.h +++ b/src/main/game/pile.h @@ -29,6 +29,8 @@ public: card& operator[] (size_type); card operator[] (size_type) const; + + friend bool operator==(const pile&, const pile&); friend std::size_t hash_value(pile const&); private: |
