replace hashmap with a dummy vector based implementation as the number of tags per object is tiny
This commit is contained in:
parent
f99f194927
commit
b06a73e893
@ -28,38 +28,51 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef HASH_TABLE_H
|
||||
#define HASH_TABLE_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
template <typename Key, typename Value> class HashTable : public std::unordered_map<Key, Value>
|
||||
template <typename Key, typename Value>
|
||||
class HashTable
|
||||
{
|
||||
private:
|
||||
typedef std::unordered_map<Key, Value> super;
|
||||
typedef std::pair<Key, Value> KeyValPair;
|
||||
std::vector<KeyValPair> table;
|
||||
|
||||
public:
|
||||
HashTable() : super() {}
|
||||
HashTable() {}
|
||||
|
||||
explicit HashTable(const unsigned size) : super(size) {}
|
||||
inline void Add(Key const &key, Value const &value)
|
||||
{
|
||||
table.emplace_back(std::move(key), std::move(value));
|
||||
}
|
||||
|
||||
inline void Add(Key const &key, Value const &value) { super::emplace(key, value); }
|
||||
inline void Clear()
|
||||
{
|
||||
table.clear();
|
||||
}
|
||||
|
||||
inline const Value Find(Key const &key) const
|
||||
{
|
||||
auto iter = super::find(key);
|
||||
if (iter == super::end())
|
||||
for (const auto &key_val_pair : table)
|
||||
{
|
||||
return Value();
|
||||
if (key_val_pair.first == key)
|
||||
{
|
||||
return key_val_pair.second;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
inline const bool Holds(Key const &key) const
|
||||
{
|
||||
if (super::find(key) == super::end())
|
||||
for (const auto &key_val_pair : table)
|
||||
{
|
||||
if (key_val_pair.first == key)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HASH_TABLE_H */
|
||||
|
@ -43,7 +43,7 @@ struct ExtractionWay
|
||||
id = SPECIAL_NODEID;
|
||||
nameID = INVALID_NAMEID;
|
||||
path.clear();
|
||||
keyVals.clear();
|
||||
keyVals.Clear();
|
||||
direction = ExtractionWay::notSure;
|
||||
speed = -1;
|
||||
backward_speed = -1;
|
||||
|
@ -40,7 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <osrm/Coordinate.h>
|
||||
|
||||
XMLParser::XMLParser(const char *filename, ExtractorCallbacks *extractor_callbacks, ScriptingEnvironment &scripting_environment)
|
||||
XMLParser::XMLParser(const char *filename,
|
||||
ExtractorCallbacks *extractor_callbacks,
|
||||
ScriptingEnvironment &scripting_environment)
|
||||
: BaseParser(extractor_callbacks, scripting_environment)
|
||||
{
|
||||
inputReader = inputReaderFactory(filename);
|
||||
@ -81,7 +83,8 @@ bool XMLParser::Parse()
|
||||
if (use_turn_restrictions && xmlStrEqual(currentName, (const xmlChar *)"relation") == 1)
|
||||
{
|
||||
InputRestrictionContainer current_restriction = ReadXMLRestriction();
|
||||
if ((UINT_MAX != current_restriction.fromWay) && !extractor_callbacks->ProcessRestriction(current_restriction))
|
||||
if ((UINT_MAX != current_restriction.fromWay) &&
|
||||
!extractor_callbacks->ProcessRestriction(current_restriction))
|
||||
{
|
||||
std::cerr << "[XMLParser] restriction not parsed" << std::endl;
|
||||
}
|
||||
@ -195,7 +198,6 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
|
||||
xmlFree(child_name);
|
||||
}
|
||||
|
||||
|
||||
if (ShouldIgnoreRestriction(except_tag_string))
|
||||
{
|
||||
restriction.fromWay = UINT_MAX; // workaround to ignore the restriction
|
||||
|
@ -38,7 +38,9 @@ class ExtractorCallbacks;
|
||||
class XMLParser : public BaseParser
|
||||
{
|
||||
public:
|
||||
XMLParser(const char *filename, ExtractorCallbacks *extractor_callbacks, ScriptingEnvironment &scripting_environment);
|
||||
XMLParser(const char *filename,
|
||||
ExtractorCallbacks *extractor_callbacks,
|
||||
ScriptingEnvironment &scripting_environment);
|
||||
bool ReadHeader();
|
||||
bool Parse();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user