diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index f010ad9572..ee98dfc95f 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -500,8 +500,7 @@ uint32_t Classificator::GetTypeByPath(vector const & path) const void Classificator::ReadTypesMapping(istream & s) { - m_i2t.Load(s); - m_t2i.Load(s); + m_mapping.Load(s); } void Classificator::Clear() diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index cc0249215f..2453b7fd74 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -203,8 +203,7 @@ class Classificator { ClassifObject m_root; - Index2Type m_i2t; - Type2Index m_t2i; + IndexAndTypeMapping m_mapping; uint32_t m_coastType; @@ -234,8 +233,8 @@ public: /// path = ["natural", "caostline"]. uint32_t GetTypeByPath(vector const & path) const; - uint32_t GetIndexForType(uint32_t t) const { return m_t2i.GetIndex(t); } - uint32_t GetTypeForIndex(uint32_t i) const { return m_i2t.GetType(i); } + uint32_t GetIndexForType(uint32_t t) const { return m_mapping.GetIndex(t); } + uint32_t GetTypeForIndex(uint32_t i) const { return m_mapping.GetType(i); } inline uint32_t GetCoastType() const { return m_coastType; } diff --git a/indexer/types_mapping.cpp b/indexer/types_mapping.cpp index ed9a8382f7..539986b109 100644 --- a/indexer/types_mapping.cpp +++ b/indexer/types_mapping.cpp @@ -5,7 +5,7 @@ #include "../base/stl_add.hpp" -void BaseTypeMapper::Load(istream & s) +void IndexAndTypeMapping::Load(istream & s) { Classificator const & c = classif(); @@ -15,6 +15,7 @@ void BaseTypeMapper::Load(istream & s) uint32_t ind = 0; while (s.good()) { + v.clear(); s >> v; if (!v.empty()) @@ -27,13 +28,10 @@ void BaseTypeMapper::Load(istream & s) } } -void Index2Type::Add(uint32_t ind, uint32_t type) +void IndexAndTypeMapping::Add(uint32_t ind, uint32_t type) { ASSERT_EQUAL ( ind, m_types.size(), () ); m_types.push_back(type); -} -void Type2Index::Add(uint32_t ind, uint32_t type) -{ VERIFY ( m_map.insert(make_pair(type, ind)).second, (type, ind) ); } diff --git a/indexer/types_mapping.hpp b/indexer/types_mapping.hpp index 79eb5a72c7..2b61e35cb5 100644 --- a/indexer/types_mapping.hpp +++ b/indexer/types_mapping.hpp @@ -6,39 +6,24 @@ #include "../std/fstream.hpp" -class BaseTypeMapper -{ -protected: - virtual void Add(uint32_t ind, uint32_t type) = 0; - -public: - void Load(istream & s); -}; - -class Index2Type : public BaseTypeMapper +class IndexAndTypeMapping { vector m_types; -protected: - virtual void Add(uint32_t ind, uint32_t type); + typedef map MapT; + MapT m_map; + + void Add(uint32_t ind, uint32_t type); public: + void Load(istream & s); + uint32_t GetType(uint32_t ind) const { ASSERT_LESS ( ind, m_types.size(), () ); return m_types[ind]; } -}; -class Type2Index : public BaseTypeMapper -{ - typedef map MapT; - MapT m_map; - -protected: - virtual void Add(uint32_t ind, uint32_t type); - -public: uint32_t GetIndex(uint32_t t) const { MapT::const_iterator i = m_map.find(t); @@ -46,5 +31,3 @@ public: return i->second; } }; - -void PrintTypesDefault(string const & fPath);