diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2015-07-30 18:12:11 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:58:18 +0300 |
commit | b81b9b214f7277c9e79925960ab77ff8fc0b0f0a (patch) | |
tree | dbaddbab42ba84bf8bcc40135f11e5087cfe5ca5 /generator | |
parent | 12da9827b65081645ecb0fdab4dfdc9c77257e1c (diff) |
Review fixes
Diffstat (limited to 'generator')
-rw-r--r-- | generator/data_cache_file.hpp | 18 | ||||
-rw-r--r-- | generator/osm_source.cpp | 9 |
2 files changed, 17 insertions, 10 deletions
diff --git a/generator/data_cache_file.hpp b/generator/data_cache_file.hpp index 3e75bc11ab..57ffbf81bd 100644 --- a/generator/data_cache_file.hpp +++ b/generator/data_cache_file.hpp @@ -23,7 +23,9 @@ namespace detail template <class TFile, class TValue> class IndexFile { - using TElement = pair<uint64_t, TValue>; + using TKey = uint64_t; + static_assert(is_integral<TKey>::value, "TKey is not integral type"); + using TElement = pair<TKey, TValue>; using TContainer = vector<TElement>; TContainer m_elements; @@ -37,8 +39,8 @@ class IndexFile { return ((r1.first == r2.first) ? r1.second < r2.second : r1.first < r2.first); } - bool operator()(TElement const & r1, uint64_t r2) const { return (r1.first < r2); } - bool operator()(uint64_t r1, TElement const & r2) const { return (r1 < r2.first); } + bool operator()(TElement const & r1, TKey r2) const { return (r1.first < r2); } + bool operator()(TKey r1, TElement const & r2) const { return (r1 < r2.first); } }; static size_t CheckedCast(uint64_t v) @@ -87,7 +89,7 @@ public: LOG_SHORT(LINFO, ("Offsets reading is finished")); } - void Write(uint64_t k, TValue const & v) + void Write(TKey k, TValue const & v) { if (m_elements.size() > kFlushCount) Flush(); @@ -95,7 +97,7 @@ public: m_elements.push_back(make_pair(k, v)); } - bool GetValueByKey(uint64_t k, TValue & v) const + bool GetValueByKey(TKey k, TValue & v) const { auto it = lower_bound(m_elements.begin(), m_elements.end(), k, ElementComparator()); if ((it != m_elements.end()) && ((*it).first == k)) @@ -107,7 +109,7 @@ public: } template <class ToDo> - void ForEachByKey(uint64_t k, ToDo && toDo) const + void ForEachByKey(TKey k, ToDo && toDo) const { auto range = equal_range(m_elements.begin(), m_elements.end(), k, ElementComparator()); for (; range.first != range.second; ++range.first) @@ -182,7 +184,9 @@ class BaseFileHolder { protected: using TKey = typename TData::TKey; - using TIndex = detail::IndexFile<TFile, uint64_t>; + static_assert(is_integral<TKey>::value, "TKey is not integral type"); + + using TIndex = detail::IndexFile<TFile, TKey>; TNodesHolder & m_nodes; diff --git a/generator/osm_source.cpp b/generator/osm_source.cpp index 9afe0f1a43..ee25f11eed 100644 --- a/generator/osm_source.cpp +++ b/generator/osm_source.cpp @@ -80,19 +80,22 @@ namespace feature return this->m_ways.Read(id, e); } - template <class ToDo> void ForEachRelationByWay(TKey id, ToDo & toDo) + template <class ToDo> + void ForEachRelationByWay(TKey id, ToDo && toDo) { RelationProcessor<ToDo> processor(this->m_relations, toDo); this->m_ways2rel.ForEachByKey(id, processor); } - template <class ToDo> void ForEachRelationByNodeCached(TKey id, ToDo & toDo) + template <class ToDo> + void ForEachRelationByNodeCached(TKey id, ToDo && toDo) { CachedRelationProcessor<ToDo> processor(this->m_relations, toDo); this->m_nodes2rel.ForEachByKey(id, processor); } - template <class ToDo> void ForEachRelationByWayCached(TKey id, ToDo & toDo) + template <class ToDo> + void ForEachRelationByWayCached(TKey id, ToDo && toDo) { CachedRelationProcessor<ToDo> processor(this->m_relations, toDo); this->m_ways2rel.ForEachByKey(id, processor); |