From: Marco Costalba Date: Sun, 26 Jul 2009 16:42:48 +0000 (+0100) Subject: Yet another small touch to endgame functions handling X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=152f3b13b78d014dbc85204d6757e2cdf65e5ecf Yet another small touch to endgame functions handling It is like a never finished painting. Everyday a little touch more. But this time it is very little ;-) No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/material.cpp b/src/material.cpp index 63901d14..eb271e8c 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -28,7 +28,7 @@ #include "material.h" -using std::string; +using namespace std; //// //// Local definitions @@ -88,21 +88,21 @@ private: static Key buildKey(const string& keyCode); static const string swapColors(const string& keyCode); - std::map EEFmap; - std::map ESFmap; + // Here we store two maps, one for evaluate and one for scaling + pair, map > maps; // Maps accessing functions for const and non-const references - template const std::map& map() const { return EEFmap; } - template std::map& map() { return EEFmap; } + template const map& get() const { return maps.first; } + template map& get() { return maps.first; } }; // Explicit specializations of a member function shall be declared in // the namespace of which the class template is a member. -template<> const std::map& -EndgameFunctions::map() const { return ESFmap; } +template<> const map& +EndgameFunctions::get() const { return maps.second; } -template<> std::map& -EndgameFunctions::map() { return ESFmap; } +template<> map& +EndgameFunctions::get() { return maps.second; } //// @@ -119,8 +119,8 @@ MaterialInfoTable::MaterialInfoTable(unsigned int numOfEntries) { funcs = new EndgameFunctions(); if (!entries || !funcs) { - std::cerr << "Failed to allocate " << (numOfEntries * sizeof(MaterialInfo)) - << " bytes for material hash table." << std::endl; + cerr << "Failed to allocate " << (numOfEntries * sizeof(MaterialInfo)) + << " bytes for material hash table." << endl; Application::exit_with_failure(); } } @@ -370,10 +370,10 @@ EndgameFunctions::EndgameFunctions() { EndgameFunctions::~EndgameFunctions() { - for (std::map::iterator it = EEFmap.begin(); it != EEFmap.end(); ++it) + for (map::iterator it = maps.first.begin(); it != maps.first.end(); ++it) delete (*it).second; - for (std::map::iterator it = ESFmap.begin(); it != ESFmap.end(); ++it) + for (map::iterator it = maps.second.begin(); it != maps.second.end(); ++it) delete (*it).second; } @@ -382,7 +382,7 @@ Key EndgameFunctions::buildKey(const string& keyCode) { assert(keyCode.length() > 0 && keyCode[0] == 'K'); assert(keyCode.length() < 8); - std::stringstream s; + stringstream s; bool upcase = false; // Build up a fen substring with the given pieces, note @@ -410,13 +410,13 @@ void EndgameFunctions::add(const string& keyCode) { typedef typename T::Base F; - map().insert(std::pair(buildKey(keyCode), new T(WHITE))); - map().insert(std::pair(buildKey(swapColors(keyCode)), new T(BLACK))); + get().insert(pair(buildKey(keyCode), new T(WHITE))); + get().insert(pair(buildKey(swapColors(keyCode)), new T(BLACK))); } template T* EndgameFunctions::get(Key key) const { - typename std::map::const_iterator it(map().find(key)); - return (it != map().end() ? it->second : NULL); + typename map::const_iterator it(get().find(key)); + return (it != get().end() ? it->second : NULL); }