浏览代码

win32: using boost::unordered_map

unknown 12 年之前
父节点
当前提交
e4fca3a26f
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 4 0
      cbaselib/ClassNames.cpp
  2. 13 1
      cbaselib/ClassNames.h

+ 4 - 0
cbaselib/ClassNames.cpp

@@ -391,7 +391,11 @@ void ClassNames::getRGBColor ( int classno, int & r, int & g, int & b ) const
 void ClassNames::getClassnoFromColor ( int & classno, int r, int g, int b ) const
 {
   long color = 256 * ( 256 * r + g ) + b;
+#if defined WIN32 && defined NICE_USELIB_BOOST  
+  boost::unordered_map<long, int>::const_iterator i = tbl_color_classno.find ( color );
+#else
   __gnu_cxx::hash_map<long, int>::const_iterator i = tbl_color_classno.find ( color );
+#endif
 
   if ( i == tbl_color_classno.end() )
   {

+ 13 - 1
cbaselib/ClassNames.h

@@ -17,7 +17,13 @@
 
 // in future we should replace this with 
 // unordered_map, but it is still experimental but standard c++
+#ifdef WIN32
+#ifdef NICE_USELIB_BOOST
+#include <boost/unordered_map.hpp>
+#endif
+#else
 #include <ext/hash_map>
+#endif
 
 #include "core/basics/Config.h"
 #include "core/basics/Persistent.h"
@@ -35,9 +41,15 @@ class ClassNames : public NICE::Persistent
     std::map<std::string, std::string> tbl_text_code;
     std::map<int, std::string> tbl_classno_code;
     std::map<std::string, int> tbl_code_classno;
-    __gnu_cxx::hash_map<long, int> tbl_color_classno;
+#if defined WIN32 && defined NICE_USELIB_BOOST
+    boost::unordered_map<long, int> tbl_color_classno;
+#else
+	__gnu_cxx::hash_map<long, int> tbl_color_classno;
+#endif
+
     std::map<int, long> tbl_classno_color;
 
+
     int maxClassNo;
 
   public: