diff --git a/indexer/feature_covering.cpp b/indexer/feature_covering.cpp index b5b15a74dd..439b905379 100644 --- a/indexer/feature_covering.cpp +++ b/indexer/feature_covering.cpp @@ -8,9 +8,6 @@ #include "geometry/covering_utils.hpp" -#include "std/vector.hpp" - - namespace { @@ -169,7 +166,7 @@ vector CoverLocality(indexer::LocalityObject const & o, int cellDepth, return CoverIntersection(fIsect, cellDepth, cellPenaltyArea); } -void SortAndMergeIntervals(IntervalsT v, IntervalsT & res) +void SortAndMergeIntervals(Intervals v, Intervals & res) { #ifdef DEBUG ASSERT ( res.empty(), () ); @@ -189,14 +186,14 @@ void SortAndMergeIntervals(IntervalsT v, IntervalsT & res) } } -IntervalsT SortAndMergeIntervals(IntervalsT const & v) +Intervals SortAndMergeIntervals(Intervals const & v) { - IntervalsT res; + Intervals res; SortAndMergeIntervals(v, res); return res; } -void AppendLowerLevels(RectId id, int cellDepth, IntervalsT & intervals) +void AppendLowerLevels(RectId id, int cellDepth, Intervals & intervals) { int64_t idInt64 = id.ToInt64(cellDepth); intervals.push_back(make_pair(idInt64, idInt64 + id.SubTreeSize(cellDepth))); @@ -208,13 +205,13 @@ void AppendLowerLevels(RectId id, int cellDepth, IntervalsT & intervals) } } -void CoverViewportAndAppendLowerLevels(m2::RectD const & r, int cellDepth, IntervalsT & res) +void CoverViewportAndAppendLowerLevels(m2::RectD const & r, int cellDepth, Intervals & res) { vector ids; ids.reserve(SPLIT_RECT_CELLS_COUNT); CoverRect(r, SPLIT_RECT_CELLS_COUNT, cellDepth, ids); - IntervalsT intervals; + Intervals intervals; for (size_t i = 0; i < ids.size(); ++i) AppendLowerLevels(ids[i], cellDepth, intervals); @@ -241,7 +238,7 @@ int GetCodingDepth(int scale) return (RectId::DEPTH_LEVELS - delta); } -IntervalsT const & CoveringGetter::Get(int scale) +Intervals const & CoveringGetter::Get(int scale) { int const cellDepth = GetCodingDepth(scale); int const ind = (cellDepth == RectId::DEPTH_LEVELS ? 0 : 1); @@ -264,7 +261,7 @@ IntervalsT const & CoveringGetter::Get(int scale) // Check for optimal result intervals. #if 0 size_t oldSize = m_res[ind].size(); - IntervalsT res; + Intervals res; SortAndMergeIntervals(m_res[ind], res); if (res.size() != oldSize) LOG(LINFO, ("Old =", oldSize, "; New =", res.size())); @@ -274,7 +271,7 @@ IntervalsT const & CoveringGetter::Get(int scale) } case FullCover: - m_res[ind].push_back(IntervalsT::value_type(0, static_cast((1ULL << 63) - 1))); + m_res[ind].push_back(Intervals::value_type(0, static_cast((1ULL << 63) - 1))); break; } } diff --git a/indexer/feature_covering.hpp b/indexer/feature_covering.hpp index eff609a4d7..3cdca66957 100644 --- a/indexer/feature_covering.hpp +++ b/indexer/feature_covering.hpp @@ -3,9 +3,8 @@ #include "coding/point_to_integer.hpp" -#include "std/utility.hpp" -#include "std/vector.hpp" - +#include +#include class FeatureType; @@ -16,48 +15,47 @@ class LocalityObject; namespace covering { - typedef pair IntervalT; - typedef vector IntervalsT; +typedef std::pair Interval; +typedef std::vector Intervals; - // Cover feature with RectIds and return their integer representations. - vector CoverFeature(FeatureType const & feature, - int cellDepth, - uint64_t cellPenaltyArea); +// Cover feature with RectIds and return their integer representations. +std::vector CoverFeature(FeatureType const & feature, int cellDepth, + uint64_t cellPenaltyArea); - vector CoverLocality(indexer::LocalityObject const & o, int cellDepth, - uint64_t cellPenaltyArea); +std::vector CoverLocality(indexer::LocalityObject const & o, int cellDepth, + uint64_t cellPenaltyArea); - void AppendLowerLevels(RectId id, int cellDepth, IntervalsT & intervals); +void AppendLowerLevels(RectId id, int cellDepth, Intervals & intervals); - // Cover viewport with RectIds and append their RectIds as well. - void CoverViewportAndAppendLowerLevels(m2::RectD const & rect, int cellDepth, - IntervalsT & intervals); +// Cover viewport with RectIds and append their RectIds as well. +void CoverViewportAndAppendLowerLevels(m2::RectD const & rect, int cellDepth, + Intervals & intervals); - // Given a vector of intervals [a, b), sort them and merge overlapping intervals. - IntervalsT SortAndMergeIntervals(IntervalsT const & intervals); +// Given a vector of intervals [a, b), sort them and merge overlapping intervals. +Intervals SortAndMergeIntervals(Intervals const & intervals); - RectId GetRectIdAsIs(m2::RectD const & r); +RectId GetRectIdAsIs(m2::RectD const & r); - // Calculate cell coding depth according to max visual scale for mwm. - int GetCodingDepth(int scale); +// Calculate cell coding depth according to max visual scale for mwm. +int GetCodingDepth(int scale); - enum CoveringMode - { - ViewportWithLowLevels = 0, - LowLevelsOnly, - FullCover - }; +enum CoveringMode +{ + ViewportWithLowLevels = 0, + LowLevelsOnly, + FullCover +}; - class CoveringGetter - { - IntervalsT m_res[2]; +class CoveringGetter +{ + Intervals m_res[2]; - m2::RectD const & m_rect; - CoveringMode m_mode; + m2::RectD const & m_rect; + CoveringMode m_mode; - public: - CoveringGetter(m2::RectD const & r, CoveringMode mode) : m_rect(r), m_mode(mode) {} +public: + CoveringGetter(m2::RectD const & r, CoveringMode mode) : m_rect(r), m_mode(mode) {} - IntervalsT const & Get(int scale); + Intervals const & Get(int scale); }; } diff --git a/indexer/index.hpp b/indexer/index.hpp index bb60541fcf..d666fb8401 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -114,7 +114,7 @@ private: scale = lastScale; // Use last coding scale for covering (see index_builder.cpp). - covering::IntervalsT const & interval = cov.Get(lastScale); + covering::Intervals const & interval = cov.Get(lastScale); // Prepare features reading. FeaturesVector const fv(pValue->m_cont, header, pValue->m_table.get()); @@ -186,7 +186,7 @@ private: scale = lastScale; // Use last coding scale for covering (see index_builder.cpp). - covering::IntervalsT const & interval = cov.Get(lastScale); + covering::Intervals const & interval = cov.Get(lastScale); ScaleIndex const index(pValue->m_cont.GetReader(INDEX_FILE_TAG), pValue->m_factory); // Iterate through intervals. diff --git a/indexer/indexer_tests/sort_and_merge_intervals_test.cpp b/indexer/indexer_tests/sort_and_merge_intervals_test.cpp index b8eefab292..c5a9dae9d7 100644 --- a/indexer/indexer_tests/sort_and_merge_intervals_test.cpp +++ b/indexer/indexer_tests/sort_and_merge_intervals_test.cpp @@ -1,6 +1,10 @@ #include "testing/testing.hpp" #include "indexer/feature_covering.hpp" +#include + +using namespace std; + UNIT_TEST(SortAndMergeIntervals_1Interval) { vector > v; diff --git a/search/mwm_context.cpp b/search/mwm_context.cpp index 637c183f05..4068f97b60 100644 --- a/search/mwm_context.cpp +++ b/search/mwm_context.cpp @@ -2,7 +2,7 @@ namespace search { -void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result) +void CoverRect(m2::RectD const & rect, int scale, covering::Intervals & result) { covering::CoveringGetter covering(rect, covering::ViewportWithLowLevels); auto const & intervals = covering.Get(scale); diff --git a/search/mwm_context.hpp b/search/mwm_context.hpp index 895a348dea..c6ada3054d 100644 --- a/search/mwm_context.hpp +++ b/search/mwm_context.hpp @@ -17,7 +17,7 @@ class MwmValue; namespace search { -void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result); +void CoverRect(m2::RectD const & rect, int scale, covering::Intervals & result); /// @todo Move this class into "index" library and make it more generic. /// Now it duplicates "Index" functionality. @@ -31,7 +31,7 @@ public: inline shared_ptr const & GetInfo() const { return GetId().GetInfo(); } template - void ForEachIndex(covering::IntervalsT const & intervals, uint32_t scale, TFn && fn) const + void ForEachIndex(covering::Intervals const & intervals, uint32_t scale, TFn && fn) const { ForEachIndexImpl(intervals, scale, [&](uint32_t index) { @@ -46,7 +46,7 @@ public: void ForEachIndex(m2::RectD const & rect, TFn && fn) const { uint32_t const scale = m_value.GetHeader().GetLastScale(); - covering::IntervalsT intervals; + covering::Intervals intervals; CoverRect(rect, scale, intervals); ForEachIndex(intervals, scale, forward(fn)); } @@ -55,7 +55,7 @@ public: void ForEachFeature(m2::RectD const & rect, TFn && fn) const { uint32_t const scale = m_value.GetHeader().GetLastScale(); - covering::IntervalsT intervals; + covering::Intervals intervals; CoverRect(rect, scale, intervals); ForEachIndexImpl(intervals, scale, [&](uint32_t index) @@ -86,7 +86,7 @@ private: } template - void ForEachIndexImpl(covering::IntervalsT const & intervals, uint32_t scale, TFn && fn) const + void ForEachIndexImpl(covering::Intervals const & intervals, uint32_t scale, TFn && fn) const { CheckUniqueIndexes checkUnique(m_value.GetHeader().GetFormat() >= version::Format::v5); for (auto const & i : intervals) diff --git a/search/retrieval.cpp b/search/retrieval.cpp index 3656da1df2..9e60e747e5 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -251,7 +251,7 @@ unique_ptr RetrieveGeometryFeaturesImpl( { EditedFeaturesHolder holder(context.GetId()); - covering::IntervalsT coverage; + covering::Intervals coverage; CoverRect(rect, scale, coverage); vector features;