diff options
author | vng <viktor.govako@gmail.com> | 2015-07-16 14:32:32 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:57:12 +0300 |
commit | 1540281383893c5ae1eeec648390ed8a00e2d0f0 (patch) | |
tree | e3f1e90a2297a022a69d6b03dfd5bda7bc7daca4 /indexer | |
parent | 8fdd97d52366659ec16cf4d4edf3ab98f96b0874 (diff) |
Distinguish feature’s ids storing policy according to mwm version (bits or raw set).
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/index.hpp | 4 | ||||
-rw-r--r-- | indexer/unique_index.hpp | 37 |
2 files changed, 28 insertions, 13 deletions
diff --git a/indexer/index.hpp b/indexer/index.hpp index 2c390db385..d7c21ba0d5 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -120,7 +120,7 @@ private: pValue->m_factory); // iterate through intervals - CheckUniqueIndexes checkUnique; + CheckUniqueIndexes checkUnique(header.GetFormat() >= version::v5); MwmId const mwmID = handle.GetId(); for (auto const & i : interval) @@ -167,7 +167,7 @@ private: pValue->m_factory); // iterate through intervals - CheckUniqueIndexes checkUnique; + CheckUniqueIndexes checkUnique(header.GetFormat() >= version::v5); MwmId const mwmID = handle.GetId(); for (auto const & i : interval) diff --git a/indexer/unique_index.hpp b/indexer/unique_index.hpp index 9578045fe1..41865773d0 100644 --- a/indexer/unique_index.hpp +++ b/indexer/unique_index.hpp @@ -2,39 +2,54 @@ #include "../base/base.hpp" +#include "../std/unordered_set.hpp" #include "../std/vector.hpp" class CheckUniqueIndexes { + unordered_set<uint32_t> m_s; vector<bool> m_v; + bool m_useBits; -public: /// Add index to the set. /// @return true If index was absent. bool Add(uint32_t ind) { - if (m_v.size() <= ind) - m_v.resize(ind + 1); - bool const ret = !m_v[ind]; - m_v[ind] = true; - return ret; + if (m_useBits) + { + if (m_v.size() <= ind) + m_v.resize(ind + 1); + bool const ret = !m_v[ind]; + m_v[ind] = true; + return ret; + } + else + return m_s.insert(ind).second; } /// Remove index from the set. /// @return true If index was present. bool Remove(uint32_t ind) { - if (m_v.size() > ind) + if (m_useBits) { - bool const ret = m_v[ind]; - m_v[ind] = false; - return ret; + if (m_v.size() > ind) + { + bool const ret = m_v[ind]; + m_v[ind] = false; + return ret; + } + else + return false; } else - return false; + return (m_s.erase(ind) > 0); } +public: + explicit CheckUniqueIndexes(bool useBits) : m_useBits(useBits) {} + bool operator()(uint32_t ind) { return Add(ind); |