diff --git a/DataStructures/HashTable.h b/DataStructures/HashTable.h index 57c2dde9f..465caca0e 100644 --- a/DataStructures/HashTable.h +++ b/DataStructures/HashTable.h @@ -24,56 +24,35 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef HASHTABLE_H_ #define HASHTABLE_H_ +#include #include template -class HashTable { - typedef boost::unordered_map MyHashTable; +class HashTable : public boost::unordered_map { +private: + typedef boost::unordered_map super; public: - typedef typename boost::unordered_map::const_iterator MyIterator; - typedef MyIterator iterator; - HashTable() { } - HashTable(const unsigned size) { - table.resize(size); - } + HashTable() : super() { } + + HashTable(const unsigned size) : super(size) { } + inline void Add(const keyT& key, const valueT& value){ - table[key] = value; - } - inline void Set(const keyT& key, const valueT& value){ - table[key] = value; + super::insert(std::make_pair(key, value)); } + inline valueT Find(const keyT& key) const { - if(table.find(key) == table.end()) + if(super::find(key) == super::end()) { return valueT(); - return table.find(key)->second; + } + return boost::ref(super::find(key)->second); } inline bool Holds(const keyT& key) const { - if(table.find(key) == table.end()) + if(super::find(key) == super::end()) { return false; + } return true; } - void EraseAll() { - if(table.size() > 0) - table.clear(); - } - - inline valueT operator[] (keyT key) const { - if(table.find(key) == table.end()) - return valueT(); - return table.find(key)->second; - } - inline unsigned Size() const { - return table.size(); - } - MyIterator begin() const { - return table.begin(); - } - MyIterator end() const { - return table.end(); - } -private: - MyHashTable table; }; #endif /* HASHTABLE_H_ */ diff --git a/DataStructures/ImportNode.h b/DataStructures/ImportNode.h index 28c9341c1..d1eb1dd28 100644 --- a/DataStructures/ImportNode.h +++ b/DataStructures/ImportNode.h @@ -46,7 +46,7 @@ struct ImportNode : public _Node { HashTable keyVals; inline void Clear() { - keyVals.EraseAll(); + keyVals.clear(); lat = 0; lon = 0; id = 0; bollard = false; trafficLight = false; } }; diff --git a/Extractor/ExtractorStructs.h b/Extractor/ExtractorStructs.h index ca8f654ad..108acf97d 100644 --- a/Extractor/ExtractorStructs.h +++ b/Extractor/ExtractorStructs.h @@ -49,7 +49,7 @@ struct ExtractionWay { id = UINT_MAX; nameID = UINT_MAX; path.clear(); - keyVals.EraseAll(); + keyVals.clear(); direction = ExtractionWay::notSure; speed = -1; backward_speed = -1; diff --git a/Extractor/PBFParser.cpp b/Extractor/PBFParser.cpp index 4f3b40fde..92338e14a 100644 --- a/Extractor/PBFParser.cpp +++ b/Extractor/PBFParser.cpp @@ -177,7 +177,7 @@ inline void PBFParser::parseDenseNode(_ThreadData * threadData) { const int keyValue = dense.keys_vals ( denseTagIndex+1 ); const std::string & key = threadData->PBFprimitiveBlock.stringtable().s(tagValue).data(); const std::string & value = threadData->PBFprimitiveBlock.stringtable().s(keyValue).data(); - extracted_nodes_vector[i].keyVals.Add(key, value); + extracted_nodes_vector[i].keyVals.insert(std::make_pair(key, value)); denseTagIndex += 2; } } @@ -306,7 +306,7 @@ inline void PBFParser::parseWay(_ThreadData * threadData) { for(int j = 0; j < number_of_keys; ++j) { const std::string & key = threadData->PBFprimitiveBlock.stringtable().s(inputWay.keys(j)); const std::string & val = threadData->PBFprimitiveBlock.stringtable().s(inputWay.vals(j)); - parsed_way_vector[i].keyVals.Add(key, val); + parsed_way_vector[i].keyVals.insert(std::make_pair(key, val)); } } diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index ab1cc8d00..0b76749dd 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -25,8 +25,9 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) { INFO("Using script " << fileName); // Create a new lua state - for(int i = 0; i < omp_get_max_threads(); ++i) + for(int i = 0; i < omp_get_max_threads(); ++i) { luaStateVector.push_back(luaL_newstate()); + } // Connect LuaBind to this lua state for all threads #pragma omp parallel @@ -85,6 +86,7 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) { luabind::value("opposite", 3) ] ]; + luabind::module(myLuaState) [ luabind::class_ >("vector") .def("Add", &std::vector::push_back) diff --git a/Plugins/NearestPlugin.h b/Plugins/NearestPlugin.h index 3fa1b7379..cb29ae002 100644 --- a/Plugins/NearestPlugin.h +++ b/Plugins/NearestPlugin.h @@ -38,8 +38,8 @@ public: NearestPlugin(QueryObjectsStorage * objects) : names(objects->names) { nodeHelpDesk = objects->nodeHelpDesk; - descriptorTable.Set("", 0); //default descriptor - descriptorTable.Set("json", 1); + descriptorTable.insert(std::make_pair("" , 0)); //default descriptor + descriptorTable.insert(std::make_pair("json", 1)); } std::string GetDescriptor() const { return std::string("nearest"); } std::string GetVersionString() const { return std::string("0.3 (DL)"); } diff --git a/Plugins/RouteParameters.h b/Plugins/RouteParameters.h index 6c2b1af3b..c6dc5c544 100644 --- a/Plugins/RouteParameters.h +++ b/Plugins/RouteParameters.h @@ -53,7 +53,7 @@ struct RouteParameters { std::string language; std::vector hints; std::vector<_Coordinate> coordinates; - typedef HashTable::MyIterator OptionsIterator; + typedef HashTable::const_iterator OptionsIterator; void setZoomLevel(const short i) { if (18 > i && 0 < i) diff --git a/Plugins/ViaRoutePlugin.h b/Plugins/ViaRoutePlugin.h index 72d27dc63..13c9e025d 100644 --- a/Plugins/ViaRoutePlugin.h +++ b/Plugins/ViaRoutePlugin.h @@ -58,9 +58,9 @@ public: searchEnginePtr = new SearchEngine(graph, nodeHelpDesk, names); - descriptorTable.Set("", 0); //default descriptor - descriptorTable.Set("json", 0); - descriptorTable.Set("gpx", 1); + descriptorTable.insert(std::make_pair("" , 0)); //default descriptor + descriptorTable.insert(std::make_pair("json", 0)); + descriptorTable.insert(std::make_pair("gpx" , 1)); } virtual ~ViaRoutePlugin() { diff --git a/extractor.cpp b/extractor.cpp index 221fb6a1e..773914c03 100644 --- a/extractor.cpp +++ b/extractor.cpp @@ -60,7 +60,9 @@ int main (int argc, char *argv[]) { unsigned number_of_threads = omp_get_num_procs(); if(testDataFile("extractor.ini")) { BaseConfiguration extractorConfig("extractor.ini"); + INFO("2"); unsigned rawNumber = stringToInt(extractorConfig.GetParameter("Threads")); + INFO("3"); if( rawNumber != 0 && rawNumber <= number_of_threads) { number_of_threads = rawNumber; }