00001 /* bookInMemory.h 00002 */ 00003 #ifndef OSL_BOOKINMEMORY_H 00004 #define OSL_BOOKINMEMORY_H 00005 #include "osl/hashKey.h" 00006 #include <unordered_map> 00007 #include <string> 00008 00009 namespace osl 00010 { 00011 namespace book 00012 { 00013 class WeightedBook; 00014 class BookInMemory 00015 { 00016 typedef CArray<Move,8> moves_t; 00017 typedef std::unordered_map<HashKey,moves_t,std::hash<HashKey>> table_t; 00018 table_t table; 00019 public: 00020 ~BookInMemory(); 00021 00022 void find(const HashKey& key, MoveVector& out) const; 00023 size_t size() const { return table.size(); } 00024 static const BookInMemory& instance(const std::string& filename=""); 00025 private: 00026 explicit BookInMemory(const std::string& filename); 00027 void readAll(const std::string& filename); 00028 int readRecursive(const HashKey& key, int index, WeightedBook& book, int, int); 00029 }; 00030 } 00031 using book::BookInMemory; 00032 } 00033 00034 #endif /* OSL_BOOKINMEMORY_H */ 00035 // ;;; Local Variables: 00036 // ;;; mode:c++ 00037 // ;;; c-basic-offset:2 00038 // ;;; End: