diff options
| author | Charlie Blake | 2018-01-18 23:57:52 +0000 |
|---|---|---|
| committer | GitHub | 2018-01-18 23:57:52 +0000 |
| commit | bcaff64bdeaab93ff0d40dfd039b4b43ff689b1c (patch) | |
| tree | 7882812349716607773458b1c830579de802793f /src/main/game/global_cache.h | |
| parent | Merge pull request #29 from thecharlesblake/refactor-improve-debug (diff) | |
| parent | Removes unnecessary assert statement bug (diff) | |
| download | metasol-bcaff64bdeaab93ff0d40dfd039b4b43ff689b1c.tar.gz metasol-bcaff64bdeaab93ff0d40dfd039b4b43ff689b1c.zip | |
Merge pull request #30 from thecharlesblake/symmetrical-hash
Symmetrical hash
Diffstat (limited to 'src/main/game/global_cache.h')
| -rw-r--r-- | src/main/game/global_cache.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/game/global_cache.h b/src/main/game/global_cache.h new file mode 100644 index 0000000..486006c --- /dev/null +++ b/src/main/game/global_cache.h @@ -0,0 +1,35 @@ +// +// Created by thecharlesblake on 1/10/18. +// + +#ifndef SOLVITAIRE_GLOBAL_CACHE_H +#define SOLVITAIRE_GLOBAL_CACHE_H + +#include <vector> +#include <unordered_set> + +#include <boost/functional/hash.hpp> + +#include "sol_rules.h" +#include "game_state.h" + +struct game_state_pred { + static bool comp_pile(const pile& x, const pile& y); + bool operator() (const game_state& x, const game_state& y) + const; +}; + +class global_cache { +public: + bool insert(const game_state&); + bool contains(const game_state&) const; + void clear(); +private: + std::unordered_set< + game_state, + boost::hash<game_state>, + game_state_pred + > u_set; +}; + +#endif //SOLVITAIRE_GLOBAL_CACHE_H |
