From c7e09657fa5cc6fd5600252b41e9774b83c0a45d Mon Sep 17 00:00:00 2001 From: Maxim Pimenov <m@maps.me> Date: Wed, 12 Sep 2018 14:22:15 +0300 Subject: [PATCH] [base] Unified stl_add and stl_helpers. --- base/CMakeLists.txt | 1 - base/base_tests/CMakeLists.txt | 3 +- base/base_tests/cache_test.cpp | 5 +- base/base_tests/regexp_test.cpp | 14 +- base/base_tests/stl_helpers_test.cpp | 152 ----------- ...stl_add_test.cpp => stl_helpers_tests.cpp} | 161 +++++++++++- base/levenshtein_dfa.cpp | 4 +- base/stl_add.hpp | 246 ------------------ base/stl_helpers.hpp | 245 ++++++++++++++++- base/string_utils.hpp | 4 +- coding/coding_tests/varint_test.cpp | 10 +- coding/geometry_coding.cpp | 2 +- coding/geometry_coding.hpp | 4 +- coding/varint.hpp | 6 +- drape/batcher.cpp | 2 +- drape/drape_tests/batcher_tests.cpp | 4 +- drape/font_texture.cpp | 2 +- drape/render_bucket.cpp | 2 +- drape/texture_manager.cpp | 2 +- drape/texture_of_colors.cpp | 2 +- drape_frontend/apply_feature_functors.cpp | 28 +- drape_frontend/frontend_renderer.cpp | 4 +- drape_frontend/gui/gui_text.cpp | 2 +- drape_frontend/gui/layer_render.cpp | 2 +- drape_frontend/message_queue.cpp | 2 +- drape_frontend/path_text_shape.cpp | 6 +- drape_frontend/read_manager.cpp | 2 +- drape_frontend/render_group.cpp | 2 +- drape_frontend/scenario_manager.hpp | 2 +- drape_frontend/tile_utils.cpp | 2 +- editor/editor_config.cpp | 2 +- editor/editor_tests/editor_config_test.cpp | 4 +- editor/edits_migration.cpp | 4 +- editor/new_feature_categories.cpp | 4 +- generator/altitude_generator.cpp | 2 +- generator/booking_dataset.cpp | 2 +- .../booking_quality_check.cpp | 2 +- generator/dumper.cpp | 2 +- generator/feature_builder.hpp | 2 +- generator/feature_generator.cpp | 2 +- generator/feature_helpers.cpp | 2 +- .../restriction_collector_test.cpp | 2 +- generator/generator_tests/types_helper.hpp | 4 +- .../generator_tests_support/test_feature.cpp | 2 +- .../test_with_custom_mwms.cpp | 2 +- generator/osm2type.cpp | 18 +- generator/osm_o5m_source.hpp | 2 +- generator/polygonizer.hpp | 2 +- .../restaurants_info/restaurants_info.cpp | 2 +- generator/restriction_collector.cpp | 2 +- generator/restriction_generator.cpp | 2 +- generator/search_index_builder.cpp | 8 +- generator/sponsored_dataset_inl.hpp | 2 +- generator/tag_admixer.hpp | 2 +- generator/unpack_mwm.cpp | 11 +- geocoder/geocoder_tests/geocoder_tests.cpp | 4 +- geometry/convex_hull.cpp | 2 +- geometry/covering.hpp | 46 ++-- geometry/geometry_tests/covering_test.cpp | 6 +- .../nearby_points_sweeper_test.cpp | 20 +- geometry/geometry_tests/polygon_test.cpp | 4 +- .../geometry_tests/simplification_test.cpp | 10 +- geometry/geometry_tests/tree_test.cpp | 18 +- geometry/polygon.hpp | 18 +- geometry/robust_orientation.hpp | 30 +-- geometry/simplification.hpp | 2 +- geometry/tree4d.hpp | 2 +- indexer/categories_holder.cpp | 6 +- indexer/categories_index.cpp | 5 +- indexer/cuisines.cpp | 4 +- indexer/feature_data.cpp | 8 +- indexer/ftypes_matcher.cpp | 4 +- indexer/ftypes_matcher.hpp | 6 +- indexer/indexer_tests/data_source_test.cpp | 2 +- indexer/indexer_tests/index_builder_test.cpp | 5 +- indexer/indexer_tests/interval_index_test.cpp | 28 +- .../indexer_tests/postcodes_matcher_tests.cpp | 2 +- indexer/map_object.hpp | 2 +- indexer/mwm_set.cpp | 4 +- indexer/postcodes_matcher.cpp | 4 +- indexer/search_string_utils.hpp | 9 +- indexer/types_mapping.cpp | 4 +- .../Core/Bookmarks/MWMBookmarksManager.mm | 4 +- .../Maps/UI/PlacePage/MWMPlacePageManager.mm | 2 +- .../Preview/MWMPPPreviewLayoutHelper.mm | 2 +- .../MWMSearchHotelsFilterViewController.mm | 6 +- kml/serdes.cpp | 2 +- kml/serdes.hpp | 2 +- local_ads/campaign_serialization.cpp | 2 +- map/cloud.cpp | 2 +- map/framework.cpp | 2 +- map/style_tests/classificator_tests.cpp | 14 +- map/user.cpp | 2 +- map/user_mark_layer.cpp | 2 +- openlr/candidate_paths_getter.cpp | 2 +- openlr/candidate_points_getter.cpp | 12 +- openlr/openlr_stat/openlr_stat.cpp | 6 +- openlr/router.cpp | 2 +- platform/measurement_utils.cpp | 2 +- platform/string_storage_base.cpp | 4 +- precompiled_headers.hpp | 2 +- qt/editor_dialog.cpp | 4 +- routing/bicycle_directions.cpp | 2 +- routing/cross_mwm_graph.cpp | 2 +- routing/fake_graph.hpp | 2 +- routing/index_router.cpp | 5 +- routing/online_absent_fetcher.cpp | 2 +- routing/restriction_loader.cpp | 2 +- routing/routing_helpers.cpp | 6 +- routing/turns.cpp | 2 +- routing/turns_generator.cpp | 2 +- search/base/mem_search_index.hpp | 3 +- search/base/text_index/mem.cpp | 2 +- search/base/text_index/merger.cpp | 7 +- search/bookmarks/processor.cpp | 2 +- search/engine.cpp | 2 +- search/feature_offset_match.hpp | 2 +- search/features_layer_path_finder.cpp | 6 +- search/geocoder.cpp | 6 +- search/geocoder_context.cpp | 2 +- search/house_detector.cpp | 4 +- search/keyword_lang_matcher.cpp | 2 +- search/keyword_matcher.cpp | 4 +- search/locality_scorer.cpp | 2 +- search/model.cpp | 18 +- search/nested_rects_cache.cpp | 2 +- search/pre_ranker.cpp | 4 +- search/processor.cpp | 9 +- search/ranker.cpp | 4 +- search/ranking_utils.hpp | 4 +- search/region_info_getter.cpp | 2 +- search/retrieval.cpp | 2 +- search/reverse_geocoder.cpp | 6 +- .../generate_tests.cpp | 4 +- .../pre_ranker_test.cpp | 4 +- search/search_quality/matcher.cpp | 2 +- .../search_quality_tool.cpp | 2 +- search/search_tests/house_detector_tests.cpp | 2 +- search/search_tests/keyword_matcher_test.cpp | 2 +- search/search_tests/locality_scorer_test.cpp | 11 +- .../search_tests/mem_search_index_tests.cpp | 5 +- search/search_tests/ranking_tests.cpp | 4 +- search/search_tests/string_match_test.cpp | 4 +- search/search_tests/text_index_tests.cpp | 4 +- search/street_vicinity_loader.cpp | 6 +- search/streets_matcher.cpp | 4 +- search/suggest.cpp | 4 +- search/tracer.cpp | 2 +- search/utils.cpp | 4 +- search/utils.hpp | 2 +- software_renderer/feature_styler.cpp | 2 +- storage/country.cpp | 2 +- storage/pinger.cpp | 2 +- storage/storage.cpp | 2 +- track_analyzing/track_matcher.cpp | 2 +- transit/transit_graph_data.cpp | 2 +- .../transit_json_parsing_test.cpp | 2 +- ugc/storage.cpp | 2 +- xcode/base/base.xcodeproj/project.pbxproj | 16 +- 159 files changed, 754 insertions(+), 807 deletions(-) delete mode 100644 base/base_tests/stl_helpers_test.cpp rename base/base_tests/{stl_add_test.cpp => stl_helpers_tests.cpp} (54%) delete mode 100644 base/stl_add.hpp diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt index 0c97898372..1365ea8f88 100644 --- a/base/CMakeLists.txt +++ b/base/CMakeLists.txt @@ -63,7 +63,6 @@ set( src_point.cpp src_point.hpp stats.hpp - stl_add.hpp stl_helpers.hpp stl_iterator.hpp string_format.cpp diff --git a/base/base_tests/CMakeLists.txt b/base/base_tests/CMakeLists.txt index 56257580aa..500b9cae61 100644 --- a/base/base_tests/CMakeLists.txt +++ b/base/base_tests/CMakeLists.txt @@ -30,8 +30,7 @@ set( rolling_hash_test.cpp scope_guard_test.cpp small_set_test.cpp - stl_add_test.cpp - stl_helpers_test.cpp + stl_helpers_tests.cpp string_format_test.cpp string_utils_test.cpp suffix_array_tests.cpp diff --git a/base/base_tests/cache_test.cpp b/base/base_tests/cache_test.cpp index 8e9ae4dc52..5c1322b33d 100644 --- a/base/base_tests/cache_test.cpp +++ b/base/base_tests/cache_test.cpp @@ -1,7 +1,8 @@ #include "testing/testing.hpp" + #include "base/cache.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <functional> @@ -86,7 +87,7 @@ UNIT_TEST(CacheSmoke_0) cache.Find(0, found); TEST(!found, ()); std::vector<char> v; - cache.ForEachValue(MakeBackInsertFunctor(v)); + cache.ForEachValue(base::MakeBackInsertFunctor(v)); TEST_EQUAL(v, std::vector<char>(8, 0), ()); } diff --git a/base/base_tests/regexp_test.cpp b/base/base_tests/regexp_test.cpp index 06e0f2921f..6c4fa912a0 100644 --- a/base/base_tests/regexp_test.cpp +++ b/base/base_tests/regexp_test.cpp @@ -1,6 +1,6 @@ #include "testing/testing.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <regex> @@ -29,7 +29,7 @@ UNIT_TEST(RegExp_ForEachMatched) { std::string const s = "6.66, 9.99"; std::vector<std::string> v; - strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); + strings::ForEachMatched(s, exp, base::MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 1, ()); TEST_EQUAL(v[0], s, ()); } @@ -38,7 +38,7 @@ UNIT_TEST(RegExp_ForEachMatched) std::string const s1 = "6.66, 9.99"; std::string const s2 = "-5.55, -7.77"; std::vector<std::string> v; - strings::ForEachMatched(s1 + " 180 , bfuewib 365@" + s2, exp, MakeBackInsertFunctor(v)); + strings::ForEachMatched(s1 + " 180 , bfuewib 365@" + s2, exp, base::MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 2, ()); TEST_EQUAL(v[0], s1, ()); TEST_EQUAL(v[1], s2, ()); @@ -47,7 +47,7 @@ UNIT_TEST(RegExp_ForEachMatched) { std::string const s = "X6.66, 9.99"; std::vector<std::string> v; - strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); + strings::ForEachMatched(s, exp, base::MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 1, ()); TEST_EQUAL(v[0], std::string(s.begin() + 1, s.end()), ()); } @@ -55,7 +55,7 @@ UNIT_TEST(RegExp_ForEachMatched) { std::string const s = "6.66, 9.99X"; std::vector<std::string> v; - strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); + strings::ForEachMatched(s, exp, base::MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 1, ()); TEST_EQUAL(v[0], std::string(s.begin(), s.end() - 1), ()); } @@ -63,14 +63,14 @@ UNIT_TEST(RegExp_ForEachMatched) { std::string const s = "6.66X, 9.99"; std::vector<std::string> v; - strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); + strings::ForEachMatched(s, exp, base::MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 0, ()); } { std::string const s = "6.66, X9.99"; std::vector<std::string> v; - strings::ForEachMatched(s, exp, MakeBackInsertFunctor(v)); + strings::ForEachMatched(s, exp, base::MakeBackInsertFunctor(v)); TEST_EQUAL(v.size(), 0, ()); } } diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp deleted file mode 100644 index 12ebe85699..0000000000 --- a/base/base_tests/stl_helpers_test.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "testing/testing.hpp" - -#include "base/stl_helpers.hpp" - -#include <algorithm> -#include <deque> -#include <utility> -#include <vector> - -namespace -{ -class Int -{ -public: - explicit Int(int v) : m_v(v) {} - - inline int Get() const { return m_v; } - -private: - int m_v; -}; - -template <template <typename...> class Cont> -void TestSortUnique() -{ - { - Cont<int> actual = {1, 2, 1, 4, 3, 5, 2, 7, 1}; - my::SortUnique(actual); - Cont<int> const expected = {1, 2, 3, 4, 5, 7}; - TEST_EQUAL(actual, expected, ()); - } - { - using Value = int; - using Pair = std::pair<Value, int>; - Cont<Pair> d = - {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}}; - - my::SortUnique(d, my::LessBy(&Pair::first), my::EqualsBy(&Pair::first)); - - Cont<Value> const expected = {1, 2, 3, 4, 5, 7}; - TEST_EQUAL(d.size(), expected.size(), ()); - for (size_t i = 0; i < d.size(); ++i) - TEST_EQUAL(d[i].first, expected[i], (i)); - } - { - using Value = double; - using Pair = std::pair<Value, int>; - Cont<Pair> d = - {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}}; - - my::SortUnique(d, my::LessBy(&Pair::first), my::EqualsBy(&Pair::first)); - - Cont<Value> const expected = {0.5, 1000.99, 1234.56789}; - TEST_EQUAL(d.size(), expected.size(), ()); - for (size_t i = 0; i < d.size(); ++i) - TEST_EQUAL(d[i].first, expected[i], (i)); - } -} - -template <template <typename...> class Cont> -void TestEqualsBy() -{ - { - using Value = std::pair<int, int>; - Cont<Value> actual = {{1, 2}, {1, 3}, {2, 100}, {3, 7}, {3, 8}, {2, 500}}; - actual.erase(std::unique(actual.begin(), actual.end(), my::EqualsBy(&Value::first)), actual.end()); - - Cont<int> const expected = {{1, 2, 3, 2}}; - TEST_EQUAL(expected.size(), actual.size(), ()); - for (size_t i = 0; i < actual.size(); ++i) - TEST_EQUAL(expected[i], actual[i].first, ()); - } - - { - Cont<Int> actual; - for (auto const v : {0, 0, 1, 2, 2, 0}) - actual.emplace_back(v); - actual.erase(std::unique(actual.begin(), actual.end(), my::EqualsBy(&Int::Get)), actual.end()); - - Cont<int> const expected = {{0, 1, 2, 0}}; - TEST_EQUAL(expected.size(), actual.size(), ()); - for (size_t i = 0; i < actual.size(); ++i) - TEST_EQUAL(expected[i], actual[i].Get(), ()); - } -} - -UNIT_TEST(LessBy) -{ - { - using Value = std::pair<int, int>; - - std::vector<Value> v = {{2, 2}, {0, 4}, {3, 1}, {4, 0}, {1, 3}}; - std::sort(v.begin(), v.end(), my::LessBy(&Value::first)); - for (size_t i = 0; i < v.size(); ++i) - TEST_EQUAL(i, static_cast<size_t>(v[i].first), ()); - - std::vector<Value const *> pv; - for (auto const & p : v) - pv.push_back(&p); - - std::sort(pv.begin(), pv.end(), my::LessBy(&Value::second)); - for (size_t i = 0; i < pv.size(); ++i) - TEST_EQUAL(i, static_cast<size_t>(pv[i]->second), ()); - } - - { - std::vector<Int> v; - for (int i = 9; i >= 0; --i) - v.emplace_back(i); - - std::sort(v.begin(), v.end(), my::LessBy(&Int::Get)); - for (size_t i = 0; i < v.size(); ++i) - TEST_EQUAL(v[i].Get(), static_cast<int>(i), ()); - } -} - -UNIT_TEST(EqualsBy_VectorTest) -{ - TestEqualsBy<std::vector>(); - TestEqualsBy<std::deque>(); -} - -UNIT_TEST(SortUnique_VectorTest) -{ - TestSortUnique<std::vector>(); - TestSortUnique<std::deque>(); -} - -UNIT_TEST(IgnoreFirstArgument) -{ - { - int s = 0; - auto f1 = [&](int a, int b) { s += a + b; }; - auto f2 = [&](int a, int b) { s -= a + b; }; - auto f3 = my::MakeIgnoreFirstArgument(f2); - - f1(2, 3); - TEST_EQUAL(s, 5, ()); - f3(1, 2, 3); - TEST_EQUAL(s, 0, ()); - } - - { - auto f1 = [](int a, int b) -> int { return a + b; }; - auto f2 = my::MakeIgnoreFirstArgument(f1); - - auto const x = f1(2, 3); - auto const y = f2("ignored", 2, 3); - TEST_EQUAL(x, y, ()); - } -} -} // namespace diff --git a/base/base_tests/stl_add_test.cpp b/base/base_tests/stl_helpers_tests.cpp similarity index 54% rename from base/base_tests/stl_add_test.cpp rename to base/base_tests/stl_helpers_tests.cpp index 82ff469580..cc76540a42 100644 --- a/base/base_tests/stl_add_test.cpp +++ b/base/base_tests/stl_helpers_tests.cpp @@ -1,22 +1,156 @@ #include "testing/testing.hpp" #include "base/macros.hpp" +#include "base/stl_helpers.hpp" -#include "base/stl_add.hpp" - +#include <algorithm> #include <deque> +#include <utility> +#include <vector> +using namespace base; -UNIT_TEST(STLAdd_IsSorted) +namespace { - TEST(IsSorted(static_cast<int*>(0), static_cast<int*>(0)), ()); - int v1[] = { 1, 3, 5 }; - int const v2[] = { 1, 3, 2 }; - TEST(!IsSorted(&v2[0], &v2[0] + ARRAY_SIZE(v2)), ()); - TEST(IsSorted(&v1[0], &v1[0] + ARRAY_SIZE(v1)), ()); - TEST(IsSorted(&v1[0], &v1[0] + 0), ()); - TEST(IsSorted(&v1[0], &v1[0] + 1), ()); - TEST(IsSorted(&v1[0], &v1[0] + 2), ()); +class Int +{ +public: + explicit Int(int v) : m_v(v) {} + + inline int Get() const { return m_v; } + +private: + int m_v; +}; + +template <template <typename...> class Cont> +void TestSortUnique() +{ + { + Cont<int> actual = {1, 2, 1, 4, 3, 5, 2, 7, 1}; + SortUnique(actual); + Cont<int> const expected = {1, 2, 3, 4, 5, 7}; + TEST_EQUAL(actual, expected, ()); + } + { + using Value = int; + using Pair = std::pair<Value, int>; + Cont<Pair> d = + {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}}; + + SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first)); + + Cont<Value> const expected = {1, 2, 3, 4, 5, 7}; + TEST_EQUAL(d.size(), expected.size(), ()); + for (size_t i = 0; i < d.size(); ++i) + TEST_EQUAL(d[i].first, expected[i], (i)); + } + { + using Value = double; + using Pair = std::pair<Value, int>; + Cont<Pair> d = + {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}}; + + SortUnique(d, LessBy(&Pair::first), EqualsBy(&Pair::first)); + + Cont<Value> const expected = {0.5, 1000.99, 1234.56789}; + TEST_EQUAL(d.size(), expected.size(), ()); + for (size_t i = 0; i < d.size(); ++i) + TEST_EQUAL(d[i].first, expected[i], (i)); + } +} + +template <template <typename...> class Cont> +void TestEqualsBy() +{ + { + using Value = std::pair<int, int>; + Cont<Value> actual = {{1, 2}, {1, 3}, {2, 100}, {3, 7}, {3, 8}, {2, 500}}; + actual.erase(std::unique(actual.begin(), actual.end(), EqualsBy(&Value::first)), actual.end()); + + Cont<int> const expected = {{1, 2, 3, 2}}; + TEST_EQUAL(expected.size(), actual.size(), ()); + for (size_t i = 0; i < actual.size(); ++i) + TEST_EQUAL(expected[i], actual[i].first, ()); + } + + { + Cont<Int> actual; + for (auto const v : {0, 0, 1, 2, 2, 0}) + actual.emplace_back(v); + actual.erase(std::unique(actual.begin(), actual.end(), EqualsBy(&Int::Get)), actual.end()); + + Cont<int> const expected = {{0, 1, 2, 0}}; + TEST_EQUAL(expected.size(), actual.size(), ()); + for (size_t i = 0; i < actual.size(); ++i) + TEST_EQUAL(expected[i], actual[i].Get(), ()); + } +} + +UNIT_TEST(LessBy) +{ + { + using Value = std::pair<int, int>; + + std::vector<Value> v = {{2, 2}, {0, 4}, {3, 1}, {4, 0}, {1, 3}}; + std::sort(v.begin(), v.end(), LessBy(&Value::first)); + for (size_t i = 0; i < v.size(); ++i) + TEST_EQUAL(i, static_cast<size_t>(v[i].first), ()); + + std::vector<Value const *> pv; + for (auto const & p : v) + pv.push_back(&p); + + std::sort(pv.begin(), pv.end(), LessBy(&Value::second)); + for (size_t i = 0; i < pv.size(); ++i) + TEST_EQUAL(i, static_cast<size_t>(pv[i]->second), ()); + } + + { + std::vector<Int> v; + for (int i = 9; i >= 0; --i) + v.emplace_back(i); + + std::sort(v.begin(), v.end(), LessBy(&Int::Get)); + for (size_t i = 0; i < v.size(); ++i) + TEST_EQUAL(v[i].Get(), static_cast<int>(i), ()); + } +} + +UNIT_TEST(EqualsBy_VectorTest) +{ + TestEqualsBy<std::vector>(); + TestEqualsBy<std::deque>(); +} + +UNIT_TEST(SortUnique_VectorTest) +{ + TestSortUnique<std::vector>(); + TestSortUnique<std::deque>(); +} + +UNIT_TEST(IgnoreFirstArgument) +{ + { + int s = 0; + auto f1 = [&](int a, int b) { s += a + b; }; + auto f2 = [&](int a, int b) { s -= a + b; }; + auto f3 = MakeIgnoreFirstArgument(f2); + + f1(2, 3); + TEST_EQUAL(s, 5, ()); + f3(1, 2, 3); + TEST_EQUAL(s, 0, ()); + } + + { + auto f1 = [](int a, int b) -> int { return a + b; }; + auto f2 = MakeIgnoreFirstArgument(f1); + + auto const x = f1(2, 3); + auto const y = f2("ignored", 2, 3); + TEST_EQUAL(x, y, ()); + } } namespace @@ -33,7 +167,7 @@ namespace } } -UNIT_TEST(STLAdd_RemoveIfKeepValid) +UNIT_TEST(RemoveIfKeepValid) { { std::vector<int> v; @@ -103,7 +237,7 @@ namespace } } -UNIT_TEST(STLAdd_AccumulateIntervals) +UNIT_TEST(AccumulateIntervals) { typedef std::pair<int, int> T; size_t idTest = 0; @@ -192,3 +326,4 @@ UNIT_TEST(STLAdd_AccumulateIntervals) CheckAccumulateIntervals(idTest, arr1, arr2, res); } } +} // namespace diff --git a/base/levenshtein_dfa.cpp b/base/levenshtein_dfa.cpp index b6bae3928b..9d1a5cf7b3 100644 --- a/base/levenshtein_dfa.cpp +++ b/base/levenshtein_dfa.cpp @@ -189,7 +189,7 @@ void LevenshteinDFA::State::Normalize() } m_positions.erase(m_positions.begin() + j, m_positions.end()); - my::SortUnique(m_positions); + base::SortUnique(m_positions); } // LevenshteinDFA ---------------------------------------------------------------------------------- @@ -211,7 +211,7 @@ LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t prefixSize, m_alphabet.insert(m_alphabet.end(), misprints.begin(), misprints.end()); } } - my::SortUnique(m_alphabet); + base::SortUnique(m_alphabet); UniChar missed = 0; for (size_t i = 0; i < m_alphabet.size() && missed >= m_alphabet[i]; ++i) diff --git a/base/stl_add.hpp b/base/stl_add.hpp deleted file mode 100644 index 2eb4909014..0000000000 --- a/base/stl_add.hpp +++ /dev/null @@ -1,246 +0,0 @@ -#pragma once - -#include <algorithm> -#include <functional> -#include <initializer_list> -#include <iterator> -#include <memory> - -namespace my -{ -using StringIL = std::initializer_list<char const *>; -} // namespace my - -template <class ContainerT> class BackInsertFunctor -{ - ContainerT & m_Container; -public: - explicit BackInsertFunctor(ContainerT & container) : m_Container(container) - { - } - void operator() (typename ContainerT::value_type const & t) const - { - m_Container.push_back(t); - } -}; - -template <class ContainerT> -BackInsertFunctor<ContainerT> MakeBackInsertFunctor(ContainerT & container) -{ - return BackInsertFunctor<ContainerT>(container); -} - -template <class ContainerT> class InsertFunctor -{ - ContainerT & m_Container; -public: - explicit InsertFunctor(ContainerT & container) : m_Container(container) - { - } - void operator() (typename ContainerT::value_type const & t) const - { - m_Container.insert(end(m_Container), t); - } -}; - -template <class ContainerT> -InsertFunctor<ContainerT> MakeInsertFunctor(ContainerT & container) -{ - return InsertFunctor<ContainerT>(container); -} - -template <class IterT, class CompareT> inline bool IsSorted(IterT beg, IterT end, CompareT comp) -{ - if (beg == end) - return true; - IterT prev = beg; - for (++beg; beg != end; ++beg, ++prev) - { - if (comp(*beg, *prev)) - return false; - } - return true; -} - -template <class IterT, class CompareT> -inline bool IsSortedAndUnique(IterT beg, IterT end, CompareT comp) -{ - if (beg == end) - return true; - IterT prev = beg; - for (++beg; beg != end; ++beg, ++prev) - { - if (!comp(*prev, *beg)) - return false; - } - return true; -} - -template <class IterT, class CompareT> -IterT RemoveIfKeepValid(IterT beg, IterT end, CompareT comp) -{ - while (beg != end) - { - if (comp(*beg)) - { - while (beg != --end) - { - if (!comp(*end)) - { - std::swap(*beg, *end); - ++beg; - break; - } - } - } - else - ++beg; - } - - return end; -} - - -template <class IterT> inline bool IsSorted(IterT beg, IterT end) -{ - return IsSorted(beg, end, std::less<typename std::iterator_traits<IterT>::value_type>()); -} - -template <class IterT> inline bool IsSortedAndUnique(IterT beg, IterT end) -{ - return IsSortedAndUnique(beg, end, std::less<typename std::iterator_traits<IterT>::value_type>()); -} - -struct DeleteFunctor -{ - template <typename T> void operator() (T const * p) const - { - delete p; - } -}; - -namespace impl -{ - template <class TContainer, class TDeletor> class DeleteRangeFunctor - { - TContainer & m_cont; - TDeletor m_deletor; - - public: - DeleteRangeFunctor(TContainer & cont, TDeletor const & deletor) - : m_cont(cont), m_deletor(deletor) - { - } - - void operator() () - { - for_each(m_cont.begin(), m_cont.end(), m_deletor); - m_cont.clear(); - } - }; -} - -template <class TContainer, class TDeletor> -impl::DeleteRangeFunctor<TContainer, TDeletor> -GetRangeDeletor(TContainer & cont, TDeletor const & deletor) -{ - return impl::DeleteRangeFunctor<TContainer, TDeletor>(cont, deletor); -} - -template <class TContainer, class TDeletor> -void DeleteRange(TContainer & cont, TDeletor const & deletor) -{ - (void)GetRangeDeletor(cont, deletor)(); -} - -struct IdFunctor -{ - template <typename T> inline T operator () (T const & x) const - { - return x; - } -}; - -template <class T> struct EqualFunctor -{ - T const & m_t; - explicit EqualFunctor(T const & t) : m_t(t) {} - inline bool operator() (T const & t) const { return (t == m_t); } -}; - -template <typename IterT> IterT NextIterInCycle(IterT it, IterT beg, IterT end) -{ - if (++it == end) - return beg; - return it; -} - -template <typename IterT> IterT PrevIterInCycle(IterT it, IterT beg, IterT end) -{ - if (it == beg) - it = end; - return --it; -} - -template <class IterT1, class IterT2, class InsertIterT> -void AccumulateIntervals1With2(IterT1 b1, IterT1 e1, IterT2 b2, IterT2 e2, InsertIterT res) -{ - //typedef typename iterator_traits<InsertIterT>::value_type T; - typedef typename std::iterator_traits<IterT1>::value_type T; - - T prev; - bool validPrev = false; - - while (b1 != e1 || b2 != e2) - { - // Try to continue previous range. - if (validPrev) - { - // add b1 range to prev if needed - if (b1 != e1 && b1->first < prev.second) - { - // correct only second if needed - if (prev.second < b1->second) - prev.second = b1->second; - ++b1; - continue; - } - - // add b2 range to prev if needed - if (b2 != e2 && b2->first < prev.second) - { - // check that intervals are overlapped - if (prev.first < b2->second) - { - // correct first and second if needed - if (b2->first < prev.first) - prev.first = b2->first; - if (prev.second < b2->second) - prev.second = b2->second; - } - - ++b2; - continue; - } - - // if nothing to add - push to results - *res++ = prev; - validPrev = false; - } - - if (b1 != e1) - { - // start new range - prev = *b1++; - validPrev = true; - } - else - { - // go to exit - break; - } - } - - if (validPrev) - *res++ = prev; -} diff --git a/base/stl_helpers.hpp b/base/stl_helpers.hpp index 7296daabc9..4ad67bed8a 100644 --- a/base/stl_helpers.hpp +++ b/base/stl_helpers.hpp @@ -2,13 +2,18 @@ #include <algorithm> #include <functional> +#include <initializer_list> +#include <iterator> +#include <memory> #include <tuple> #include <type_traits> #include <utility> #include <vector> -namespace my +namespace base { +using StringIL = std::initializer_list<char const *>; + namespace impl { // When isField is true, following functors operate on a @@ -22,9 +27,9 @@ struct Less<true, T, C> { Less(T(C::*p)) : m_p(p) {} - inline bool operator()(C const & lhs, C const & rhs) const { return lhs.*m_p < rhs.*m_p; } + bool operator()(C const & lhs, C const & rhs) const { return lhs.*m_p < rhs.*m_p; } - inline bool operator()(C const * const lhs, C const * const rhs) const + bool operator()(C const * const lhs, C const * const rhs) const { return lhs->*m_p < rhs->*m_p; } @@ -37,9 +42,9 @@ struct Less<false, T, C> { Less(T (C::*p)() const) : m_p(p) {} - inline bool operator()(C const & lhs, C const & rhs) const { return (lhs.*m_p)() < (rhs.*m_p)(); } + bool operator()(C const & lhs, C const & rhs) const { return (lhs.*m_p)() < (rhs.*m_p)(); } - inline bool operator()(C const * const lhs, C const * const rhs) const + bool operator()(C const * const lhs, C const * const rhs) const { return (lhs->*m_p)() < (rhs->*m_p)(); } @@ -55,9 +60,9 @@ struct Equals<true, T, C> { Equals(T(C::*p)) : m_p(p) {} - inline bool operator()(C const & lhs, C const & rhs) const { return lhs.*m_p == rhs.*m_p; } + bool operator()(C const & lhs, C const & rhs) const { return lhs.*m_p == rhs.*m_p; } - inline bool operator()(C const * const lhs, C const * const rhs) const + bool operator()(C const * const lhs, C const * const rhs) const { return lhs->*m_p == rhs->*m_p; } @@ -70,15 +75,34 @@ struct Equals<false, T, C> { Equals(T (C::*p)() const) : m_p(p) {} - inline bool operator()(C const & lhs, C const & rhs) const { return (lhs.*m_p)() == (rhs.*m_p)(); } + bool operator()(C const & lhs, C const & rhs) const { return (lhs.*m_p)() == (rhs.*m_p)(); } - inline bool operator()(C const * const lhs, C const * const rhs) const + bool operator()(C const * const lhs, C const * const rhs) const { return (lhs->*m_p)() == (rhs->*m_p)(); } T (C::*m_p)() const; }; + +template <typename Container, typename Deletor> +class DeleteRangeFunctor +{ +public: + DeleteRangeFunctor(Container & cont, Deletor const & deletor) : m_cont(cont), m_deletor(deletor) + { + } + + void operator()() + { + for_each(m_cont.begin(), m_cont.end(), m_deletor); + m_cont.clear(); + } + +private: + Container & m_cont; + Deletor m_deletor; +}; } // namespace impl // Sorts and removes duplicate entries from |c|. @@ -92,14 +116,14 @@ void SortUnique(Cont & c) // Sorts according to |less| and removes duplicate entries according to |equals| from |c|. // Note. If several entries are equal according to |less| an arbitrary entry of them // is left in |c| after a call of this function. -template <class Cont, typename Less, typename Equals> +template <typename Cont, typename Less, typename Equals> void SortUnique(Cont & c, Less && less, Equals && equals) { sort(c.begin(), c.end(), std::forward<Less>(less)); c.erase(unique(c.begin(), c.end(), std::forward<Equals>(equals)), c.end()); } -template <class Cont, class Fn> +template <typename Cont, typename Fn> void EraseIf(Cont & c, Fn && fn) { c.erase(remove_if(c.begin(), c.end(), std::forward<Fn>(fn)), c.end()); @@ -193,4 +217,201 @@ for_each_in_tuple_const(std::tuple<Tp...> const & t, Fn && fn) for_each_in_tuple_const<I + 1, Fn, Tp...>(t, std::forward<Fn>(fn)); } -} // namespace my +template <typename Container> +class BackInsertFunctor +{ +public: + explicit BackInsertFunctor(Container & container) : m_Container(container) {} + void operator()(typename Container::value_type const & t) const { m_Container.push_back(t); } + +private: + Container & m_Container; +}; + +template <typename Container> +BackInsertFunctor<Container> MakeBackInsertFunctor(Container & container) +{ + return BackInsertFunctor<Container>(container); +} + +template <typename Container> +class InsertFunctor +{ +public: + explicit InsertFunctor(Container & container) : m_Container(container) {} + void operator()(typename Container::value_type const & t) const + { + m_Container.insert(end(m_Container), t); + } + +private: + Container & m_Container; +}; + +template <typename Container> +InsertFunctor<Container> MakeInsertFunctor(Container & container) +{ + return InsertFunctor<Container>(container); +} + +template <typename Iter, typename Compare> +bool IsSortedAndUnique(Iter beg, Iter end, Compare comp) +{ + if (beg == end) + return true; + Iter prev = beg; + for (++beg; beg != end; ++beg, ++prev) + { + if (!comp(*prev, *beg)) + return false; + } + return true; +} + +template <typename Iter, typename Compare> +Iter RemoveIfKeepValid(Iter beg, Iter end, Compare comp) +{ + while (beg != end) + { + if (comp(*beg)) + { + while (beg != --end) + { + if (!comp(*end)) + { + std::swap(*beg, *end); + ++beg; + break; + } + } + } + else + ++beg; + } + + return end; +} + +template <typename Iter> +bool IsSortedAndUnique(Iter beg, Iter end) +{ + return IsSortedAndUnique(beg, end, std::less<typename std::iterator_traits<Iter>::value_type>()); +} + +struct DeleteFunctor +{ + template <typename T> + void operator()(T const * p) const + { + delete p; + } +}; + +template <typename Container, typename Deletor> +impl::DeleteRangeFunctor<Container, Deletor> GetRangeDeletor(Container & cont, + Deletor const & deletor) +{ + return impl::DeleteRangeFunctor<Container, Deletor>(cont, deletor); +} + +template <typename Container, typename Deletor> +void DeleteRange(Container & cont, Deletor const & deletor) +{ + (void)GetRangeDeletor(cont, deletor)(); +} + +struct IdFunctor +{ + template <typename T> + T operator()(T const & x) const + { + return x; + } +}; + +template <typename T> +struct EqualFunctor +{ + T const & m_t; + explicit EqualFunctor(T const & t) : m_t(t) {} + bool operator()(T const & t) const { return (t == m_t); } +}; + +template <typename Iter> +Iter NextIterInCycle(Iter it, Iter beg, Iter end) +{ + if (++it == end) + return beg; + return it; +} + +template <typename Iter> +Iter PrevIterInCycle(Iter it, Iter beg, Iter end) +{ + if (it == beg) + it = end; + return --it; +} + +template <typename Iter1, typename Iter2, typename InsertIter> +void AccumulateIntervals1With2(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, InsertIter res) +{ + using T = typename std::iterator_traits<Iter1>::value_type; + + T prev; + bool validPrev = false; + + while (b1 != e1 || b2 != e2) + { + // Try to continue previous range. + if (validPrev) + { + // add b1 range to prev if needed + if (b1 != e1 && b1->first < prev.second) + { + // correct only second if needed + if (prev.second < b1->second) + prev.second = b1->second; + ++b1; + continue; + } + + // add b2 range to prev if needed + if (b2 != e2 && b2->first < prev.second) + { + // check that intervals are overlapped + if (prev.first < b2->second) + { + // correct first and second if needed + if (b2->first < prev.first) + prev.first = b2->first; + if (prev.second < b2->second) + prev.second = b2->second; + } + + ++b2; + continue; + } + + // if nothing to add - push to results + *res++ = prev; + validPrev = false; + } + + if (b1 != e1) + { + // start new range + prev = *b1++; + validPrev = true; + } + else + { + // go to exit + break; + } + } + + if (validPrev) + *res++ = prev; +} +} // namespace base diff --git a/base/string_utils.hpp b/base/string_utils.hpp index 3fe0807500..778818b018 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -2,7 +2,7 @@ #include "base/buffer_vector.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <cstdint> @@ -317,7 +317,7 @@ template <template <typename ...> class Collection = std::vector> Collection<std::string> Tokenize(std::string const & str, char const * delims) { Collection<std::string> c; - Tokenize(str, delims, MakeInsertFunctor(c)); + Tokenize(str, delims, base::MakeInsertFunctor(c)); return c; } diff --git a/coding/coding_tests/varint_test.cpp b/coding/coding_tests/varint_test.cpp index 102f5694f1..fca5cc0fd3 100644 --- a/coding/coding_tests/varint_test.cpp +++ b/coding/coding_tests/varint_test.cpp @@ -4,7 +4,7 @@ #include "coding/byte_stream.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <vector> @@ -111,10 +111,10 @@ UNIT_TEST(VarIntMax) UNIT_TEST(ReadVarInt64Array_EmptyArray) { vector<int64_t> result; - void const * pEnd = ReadVarInt64Array(NULL, (void *)0, MakeBackInsertFunctor(result)); + void const * pEnd = ReadVarInt64Array(NULL, (void *)0, base::MakeBackInsertFunctor(result)); TEST_EQUAL(result, vector<int64_t>(), ("UntilBufferEnd")); TEST_EQUAL(reinterpret_cast<uintptr_t>(pEnd), 0, ("UntilBufferEnd")); - pEnd = ReadVarInt64Array(NULL, (size_t)0, MakeBackInsertFunctor(result)); + pEnd = ReadVarInt64Array(NULL, (size_t)0, base::MakeBackInsertFunctor(result)); TEST_EQUAL(result, vector<int64_t>(), ("GivenSize")); TEST_EQUAL(reinterpret_cast<uintptr_t>(pEnd), 0, ("GivenSize")); } @@ -165,7 +165,7 @@ UNIT_TEST(ReadVarInt64Array) vector<int64_t> result; void const * pEnd = ReadVarInt64Array(pDataStart, pDataEnd, - MakeBackInsertFunctor(result)); + base::MakeBackInsertFunctor(result)); TEST_EQUAL(pEnd, pDataEnd, ("UntilBufferEnd", data.size())); TEST_EQUAL(result, testValues, ("UntilBufferEnd", data.size())); @@ -173,7 +173,7 @@ UNIT_TEST(ReadVarInt64Array) { vector<int64_t> result; void const * pEnd = ReadVarInt64Array(&data[0], testValues.size(), - MakeBackInsertFunctor(result)); + base::MakeBackInsertFunctor(result)); TEST_EQUAL(pEnd, &data[0] + data.size(), ("GivenSize", data.size())); TEST_EQUAL(result, testValues, ("GivenSize", data.size())); diff --git a/coding/geometry_coding.cpp b/coding/geometry_coding.cpp index a3c84d8fd8..90ba013f2b 100644 --- a/coding/geometry_coding.cpp +++ b/coding/geometry_coding.cpp @@ -375,7 +375,7 @@ void const * LoadInner(DecodeFunT fn, void const * pBeg, size_t count, DeltasT deltas; deltas.reserve(count); void const * ret = - ReadVarUint64Array(static_cast<char const *>(pBeg), count, MakeBackInsertFunctor(deltas)); + ReadVarUint64Array(static_cast<char const *>(pBeg), count, base::MakeBackInsertFunctor(deltas)); Decode(fn, deltas, params, points); return ret; diff --git a/coding/geometry_coding.hpp b/coding/geometry_coding.hpp index d54e37ffe8..26b8db04e4 100644 --- a/coding/geometry_coding.hpp +++ b/coding/geometry_coding.hpp @@ -12,7 +12,7 @@ #include "base/base.hpp" #include "base/bits.hpp" #include "base/buffer_vector.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <cstddef> @@ -251,7 +251,7 @@ void LoadOuter(DecodeFunT fn, TSource & src, GeometryCodingParams const & params DeltasT deltas; deltas.reserve(count / 2); - ReadVarUint64Array(p, p + count, MakeBackInsertFunctor(deltas)); + ReadVarUint64Array(p, p + count, base::MakeBackInsertFunctor(deltas)); Decode(fn, deltas, params, points, reserveF); } diff --git a/coding/varint.hpp b/coding/varint.hpp index 8754c567ce..b5de27a01a 100644 --- a/coding/varint.hpp +++ b/coding/varint.hpp @@ -6,7 +6,7 @@ #include "base/base.hpp" #include "base/bits.hpp" #include "base/exception.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <cstddef> #include <type_traits> @@ -257,7 +257,7 @@ void const * ReadVarInt64Array(void const * pBeg, void const * pEnd, F f) template <typename F> inline void const * ReadVarUint64Array(void const * pBeg, void const * pEnd, F f) { - return impl::ReadVarInt64Array(pBeg, impl::ReadVarInt64ArrayUntilBufferEnd(pEnd), f, IdFunctor()); + return impl::ReadVarInt64Array(pBeg, impl::ReadVarInt64ArrayUntilBufferEnd(pEnd), f, base::IdFunctor()); } template <typename F> inline @@ -270,7 +270,7 @@ void const * ReadVarInt64Array(void const * pBeg, size_t count, F f) template <typename F> inline void const * ReadVarUint64Array(void const * pBeg, size_t count, F f) { - return impl::ReadVarInt64Array(pBeg, impl::ReadVarInt64ArrayGivenSize(count), f, IdFunctor()); + return impl::ReadVarInt64Array(pBeg, impl::ReadVarInt64ArrayGivenSize(count), f, base::IdFunctor()); } template <class Cont, class Sink> diff --git a/drape/batcher.cpp b/drape/batcher.cpp index 4b7b6b8b76..cb9e0c5949 100644 --- a/drape/batcher.cpp +++ b/drape/batcher.cpp @@ -6,7 +6,7 @@ #include "drape/vertex_array_buffer.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/bind.hpp" diff --git a/drape/drape_tests/batcher_tests.cpp b/drape/drape_tests/batcher_tests.cpp index 8b4ae0f489..f4c04bb6e9 100644 --- a/drape/drape_tests/batcher_tests.cpp +++ b/drape/drape_tests/batcher_tests.cpp @@ -7,7 +7,7 @@ #include "drape/index_storage.hpp" #include "drape/vertex_array_buffer.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <cstring> #include <functional> @@ -262,7 +262,7 @@ public: ~PartialBatcherTest() { - std::for_each(m_comparators.begin(), m_comparators.end(), DeleteFunctor()); + std::for_each(m_comparators.begin(), m_comparators.end(), base::DeleteFunctor()); } void AddBufferNode(BufferNode const & node) diff --git a/drape/font_texture.cpp b/drape/font_texture.cpp index be50124bf1..5f623056c7 100644 --- a/drape/font_texture.cpp +++ b/drape/font_texture.cpp @@ -6,8 +6,8 @@ #include "coding/reader.hpp" #include "base/logging.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" -#include "base/stl_add.hpp" #include <algorithm> #include <functional> diff --git a/drape/render_bucket.cpp b/drape/render_bucket.cpp index c4f5567846..7f6beb22be 100644 --- a/drape/render_bucket.cpp +++ b/drape/render_bucket.cpp @@ -6,7 +6,7 @@ #include "drape/overlay_tree.hpp" #include "drape/vertex_array_buffer.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/bind.hpp" namespace dp diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp index d0c2bb2eed..16a5fb496b 100644 --- a/drape/texture_manager.cpp +++ b/drape/texture_manager.cpp @@ -14,7 +14,7 @@ #include "base/buffer_vector.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <algorithm> diff --git a/drape/texture_of_colors.cpp b/drape/texture_of_colors.cpp index 3194fbcf9d..45cfb1c880 100644 --- a/drape/texture_of_colors.cpp +++ b/drape/texture_of_colors.cpp @@ -1,7 +1,7 @@ #include "drape/texture_of_colors.hpp" #include "base/shared_buffer_manager.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <cstring> diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp index f5d7b58212..66ac6ec91b 100644 --- a/drape_frontend/apply_feature_functors.cpp +++ b/drape_frontend/apply_feature_functors.cpp @@ -314,16 +314,16 @@ dp::FontDecl GetRoadShieldTextFont(dp::FontDecl const & baseFont, ftypes::RoadSh using ftypes::RoadShieldType; static std::unordered_map<int, df::ColorConstant> kColors = { - {my::Key(RoadShieldType::Generic_Green), kRoadShieldWhiteTextColor}, - {my::Key(RoadShieldType::Generic_Blue), kRoadShieldWhiteTextColor}, - {my::Key(RoadShieldType::UK_Highway), kRoadShieldUKYellowTextColor}, - {my::Key(RoadShieldType::US_Interstate), kRoadShieldWhiteTextColor}, - {my::Key(RoadShieldType::US_Highway), kRoadShieldBlackTextColor}, - {my::Key(RoadShieldType::Generic_Red), kRoadShieldWhiteTextColor}, - {my::Key(RoadShieldType::Generic_Orange), kRoadShieldBlackTextColor} + {base::Key(RoadShieldType::Generic_Green), kRoadShieldWhiteTextColor}, + {base::Key(RoadShieldType::Generic_Blue), kRoadShieldWhiteTextColor}, + {base::Key(RoadShieldType::UK_Highway), kRoadShieldUKYellowTextColor}, + {base::Key(RoadShieldType::US_Interstate), kRoadShieldWhiteTextColor}, + {base::Key(RoadShieldType::US_Highway), kRoadShieldBlackTextColor}, + {base::Key(RoadShieldType::Generic_Red), kRoadShieldWhiteTextColor}, + {base::Key(RoadShieldType::Generic_Orange), kRoadShieldBlackTextColor} }; - auto it = kColors.find(my::Key(shield.m_type)); + auto it = kColors.find(base::Key(shield.m_type)); if (it != kColors.end()) f.m_color = df::GetColorConstant(it->second); @@ -335,14 +335,14 @@ dp::Color GetRoadShieldColor(dp::Color const & baseColor, ftypes::RoadShield con using ftypes::RoadShieldType; static std::unordered_map<int, df::ColorConstant> kColors = { - {my::Key(RoadShieldType::Generic_Green), kRoadShieldGreenBackgroundColor}, - {my::Key(RoadShieldType::Generic_Blue), kRoadShieldBlueBackgroundColor}, - {my::Key(RoadShieldType::UK_Highway), kRoadShieldGreenBackgroundColor}, - {my::Key(RoadShieldType::Generic_Red), kRoadShieldRedBackgroundColor}, - {my::Key(RoadShieldType::Generic_Orange), kRoadShieldOrangeBackgroundColor} + {base::Key(RoadShieldType::Generic_Green), kRoadShieldGreenBackgroundColor}, + {base::Key(RoadShieldType::Generic_Blue), kRoadShieldBlueBackgroundColor}, + {base::Key(RoadShieldType::UK_Highway), kRoadShieldGreenBackgroundColor}, + {base::Key(RoadShieldType::Generic_Red), kRoadShieldRedBackgroundColor}, + {base::Key(RoadShieldType::Generic_Orange), kRoadShieldOrangeBackgroundColor} }; - auto it = kColors.find(my::Key(shield.m_type)); + auto it = kColors.find(base::Key(shield.m_type)); if (it != kColors.end()) return df::GetColorConstant(it->second); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 7ff07c64a3..f8d481b089 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -29,10 +29,10 @@ #include "geometry/any_rect2d.hpp" -#include "base/timer.hpp" #include "base/assert.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" +#include "base/timer.hpp" #include <algorithm> #include <chrono> diff --git a/drape_frontend/gui/gui_text.cpp b/drape_frontend/gui/gui_text.cpp index 8f7b4c77e1..a4f7d98668 100644 --- a/drape_frontend/gui/gui_text.cpp +++ b/drape_frontend/gui/gui_text.cpp @@ -4,8 +4,8 @@ #include "shaders/programs.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" -#include "base/stl_add.hpp" #include "drape/bidi.hpp" #include "drape/glsl_func.hpp" diff --git a/drape_frontend/gui/layer_render.cpp b/drape_frontend/gui/layer_render.cpp index 75c24fe7d3..15bf497f1c 100644 --- a/drape_frontend/gui/layer_render.cpp +++ b/drape_frontend/gui/layer_render.cpp @@ -18,7 +18,7 @@ #include "geometry/mercator.hpp" #include "geometry/point2d.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <ios> #include <functional> diff --git a/drape_frontend/message_queue.cpp b/drape_frontend/message_queue.cpp index 8ff981910e..5d6b1c27f8 100644 --- a/drape_frontend/message_queue.cpp +++ b/drape_frontend/message_queue.cpp @@ -1,7 +1,7 @@ #include "drape_frontend/message_queue.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" namespace df { diff --git a/drape_frontend/path_text_shape.cpp b/drape_frontend/path_text_shape.cpp index d8e046c715..9795a38de4 100644 --- a/drape_frontend/path_text_shape.cpp +++ b/drape_frontend/path_text_shape.cpp @@ -8,12 +8,12 @@ #include "drape/batcher.hpp" #include "drape/overlay_handle.hpp" -#include "base/math.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/math.hpp" +#include "base/matrix.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "base/timer.hpp" -#include "base/matrix.hpp" #include "geometry/transformations.hpp" diff --git a/drape_frontend/read_manager.cpp b/drape_frontend/read_manager.cpp index af3339670a..3a336b1705 100755 --- a/drape_frontend/read_manager.cpp +++ b/drape_frontend/read_manager.cpp @@ -6,7 +6,7 @@ #include "drape/constants.hpp" #include "base/buffer_vector.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <functional> diff --git a/drape_frontend/render_group.cpp b/drape_frontend/render_group.cpp index 8791b15235..c7723d1716 100755 --- a/drape_frontend/render_group.cpp +++ b/drape_frontend/render_group.cpp @@ -8,7 +8,7 @@ #include "geometry/screenbase.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <sstream> diff --git a/drape_frontend/scenario_manager.hpp b/drape_frontend/scenario_manager.hpp index a174a62095..d158c1fdc4 100644 --- a/drape_frontend/scenario_manager.hpp +++ b/drape_frontend/scenario_manager.hpp @@ -6,7 +6,7 @@ #include "geometry/point2d.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/thread.hpp" #include <chrono> diff --git a/drape_frontend/tile_utils.cpp b/drape_frontend/tile_utils.cpp index b29cf02e90..e8bdcaf2db 100755 --- a/drape_frontend/tile_utils.cpp +++ b/drape_frontend/tile_utils.cpp @@ -5,7 +5,7 @@ #include "geometry/mercator.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" namespace df { diff --git a/editor/editor_config.cpp b/editor/editor_config.cpp index bd77345010..d34172189f 100644 --- a/editor/editor_config.cpp +++ b/editor/editor_config.cpp @@ -88,7 +88,7 @@ bool TypeDescriptionFromXml(pugi::xml_node const & root, pugi::xml_node const & handleField(fieldName); } - my::SortUnique(outDesc.m_editableFields); + base::SortUnique(outDesc.m_editableFields); return true; } diff --git a/editor/editor_tests/editor_config_test.cpp b/editor/editor_tests/editor_config_test.cpp index c8fbd02f4a..7666d23a2a 100644 --- a/editor/editor_tests/editor_config_test.cpp +++ b/editor/editor_tests/editor_config_test.cpp @@ -46,7 +46,7 @@ UNIT_TEST(EditorConfig_TypeDescription) TEST(desc.IsAddressEditable(), ()); auto fields = poi; fields.push_back(EType::FMD_INTERNET); - my::SortUnique(fields); + base::SortUnique(fields); TEST_EQUAL(desc.GetEditableFields(), fields, ()); } { @@ -57,7 +57,7 @@ UNIT_TEST(EditorConfig_TypeDescription) TEST(desc.IsAddressEditable(), ()); auto fields = poi; fields.push_back(EType::FMD_OPERATOR); - my::SortUnique(fields); + base::SortUnique(fields); TEST_EQUAL(desc.GetEditableFields(), fields, ()); } { diff --git a/editor/edits_migration.cpp b/editor/edits_migration.cpp index fb5ae5627e..d04738efe7 100644 --- a/editor/edits_migration.cpp +++ b/editor/edits_migration.cpp @@ -78,8 +78,8 @@ FeatureID MigrateWayOrRelatonFeatureIndex( { // Support migration for old application versions. // TODO(a): To remove it when version 8.0.x will no longer be supported. - my::SortUnique(geometry); - my::SortUnique(ftGeometry); + base::SortUnique(geometry); + base::SortUnique(ftGeometry); score = matcher::ScoreTriangulatedGeometriesByPoints(geometry, ftGeometry); } diff --git a/editor/new_feature_categories.cpp b/editor/new_feature_categories.cpp index cc67efb220..7ac92c84fc 100644 --- a/editor/new_feature_categories.cpp +++ b/editor/new_feature_categories.cpp @@ -56,7 +56,7 @@ void NewFeatureCategories::AddLanguage(string lang) m_index.AddCategoryByTypeAndLang(type, langCode); names.emplace_back(m_index.GetCategoriesHolder()->GetReadableFeatureType(type, langCode), type); } - my::SortUnique(names); + base::SortUnique(names); m_categoriesByLang[lang] = names; } @@ -78,7 +78,7 @@ NewFeatureCategories::TNames NewFeatureCategories::Search(string const & query, m_index.GetCategoriesHolder()->GetReadableFeatureType(resultTypes[i], langCode); result[i].second = resultTypes[i]; } - my::SortUnique(result); + base::SortUnique(result); alohalytics::TStringMap const stats = { {"query", query}, {"lang", lang}}; diff --git a/generator/altitude_generator.cpp b/generator/altitude_generator.cpp index 4417f688e4..65c5236920 100644 --- a/generator/altitude_generator.cpp +++ b/generator/altitude_generator.cpp @@ -141,7 +141,7 @@ public: bool IsFeatureAltitudesSorted() { return std::is_sorted(m_featureAltitudes.begin(), m_featureAltitudes.end(), - my::LessBy(&Processor::FeatureAltitude::m_featureId)); + base::LessBy(&Processor::FeatureAltitude::m_featureId)); } private: diff --git a/generator/booking_dataset.cpp b/generator/booking_dataset.cpp index 22e741de36..58ccd88da0 100644 --- a/generator/booking_dataset.cpp +++ b/generator/booking_dataset.cpp @@ -70,7 +70,7 @@ void BookingDataset::PreprocessMatchedOsmObject(ObjectId, FeatureBuilder1 & fb, meta.Drop(feature::Metadata::EType::FMD_PHONE_NUMBER); auto const tourism = classif().GetTypeByPath({"tourism"}); - my::EraseIf(params.m_types, [tourism](uint32_t type) + base::EraseIf(params.m_types, [tourism](uint32_t type) { ftype::TruncValue(type, 1); return type == tourism; diff --git a/generator/booking_quality_check/booking_quality_check.cpp b/generator/booking_quality_check/booking_quality_check.cpp index 95c6feb994..4acc3d52bb 100644 --- a/generator/booking_quality_check/booking_quality_check.cpp +++ b/generator/booking_quality_check/booking_quality_check.cpp @@ -13,7 +13,7 @@ #include "base/exception.hpp" #include "base/geo_object_id.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cstdlib> diff --git a/generator/dumper.cpp b/generator/dumper.cpp index f0e7676018..57e1dae2ea 100644 --- a/generator/dumper.cpp +++ b/generator/dumper.cpp @@ -131,7 +131,7 @@ namespace feature vector<strings::UniString> tokens; search::SplitUniString(search::NormalizeAndSimplifyString(name), - MakeBackInsertFunctor(tokens), search::Delimiters()); + base::MakeBackInsertFunctor(tokens), search::Delimiters()); if (tokens.empty()) return; diff --git a/generator/feature_builder.hpp b/generator/feature_builder.hpp index 7726b3fa32..ef8ad0bd4a 100644 --- a/generator/feature_builder.hpp +++ b/generator/feature_builder.hpp @@ -88,7 +88,7 @@ public: template <class FnT> bool RemoveTypesIf(FnT fn) { - my::EraseIf(m_params.m_types, fn); + base::EraseIf(m_params.m_types, fn); return m_params.m_types.empty(); } diff --git a/generator/feature_generator.cpp b/generator/feature_generator.cpp index 46de27f5d5..9d89e701cd 100644 --- a/generator/feature_generator.cpp +++ b/generator/feature_generator.cpp @@ -13,7 +13,7 @@ #include "base/assert.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <functional> #include "std/target_os.hpp" diff --git a/generator/feature_helpers.cpp b/generator/feature_helpers.cpp index a3ef111244..e8299ea5c8 100644 --- a/generator/feature_helpers.cpp +++ b/generator/feature_helpers.cpp @@ -55,6 +55,6 @@ m2::PointD CalculateMidPoints::GetCenter() const void CalculateMidPoints::Sort() { - sort(m_vec.begin(), m_vec.end(), my::LessBy(&CellAndOffset::first)); + sort(m_vec.begin(), m_vec.end(), base::LessBy(&CellAndOffset::first)); } } // namespace feature diff --git a/generator/generator_tests/restriction_collector_test.cpp b/generator/generator_tests/restriction_collector_test.cpp index f7cb0a10b0..2ec9bca738 100644 --- a/generator/generator_tests/restriction_collector_test.cpp +++ b/generator/generator_tests/restriction_collector_test.cpp @@ -48,7 +48,7 @@ UNIT_TEST(RestrictionTest_ValidCase) TEST(restrictionCollector.AddRestriction(Restriction::Type::Only, {base::MakeOsmWay(5), base::MakeOsmWay(7)}), ()); - my::SortUnique(restrictionCollector.m_restrictions); + base::SortUnique(restrictionCollector.m_restrictions); // Checking the result. TEST(restrictionCollector.IsValid(), ()); diff --git a/generator/generator_tests/types_helper.hpp b/generator/generator_tests/types_helper.hpp index b8173e81b5..a044ab4dbe 100644 --- a/generator/generator_tests/types_helper.hpp +++ b/generator/generator_tests/types_helper.hpp @@ -5,7 +5,7 @@ #include "indexer/classificator.hpp" #include "indexer/feature_data.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <string> #include <vector> @@ -36,7 +36,7 @@ inline uint32_t GetType(char const * (&arr)[N]) return classif().GetTypeByPath(path); } -inline uint32_t GetType(my::StringIL const & lst) +inline uint32_t GetType(base::StringIL const & lst) { return classif().GetTypeByPath(lst); } diff --git a/generator/generator_tests_support/test_feature.cpp b/generator/generator_tests_support/test_feature.cpp index bcc52da32b..f540523701 100644 --- a/generator/generator_tests_support/test_feature.cpp +++ b/generator/generator_tests_support/test_feature.cpp @@ -16,7 +16,7 @@ #include "coding/multilang_utf8_string.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <atomic> diff --git a/generator/generator_tests_support/test_with_custom_mwms.cpp b/generator/generator_tests_support/test_with_custom_mwms.cpp index 6e123a7935..f16c205a2d 100644 --- a/generator/generator_tests_support/test_with_custom_mwms.cpp +++ b/generator/generator_tests_support/test_with_custom_mwms.cpp @@ -2,7 +2,7 @@ #include "platform/local_country_file_utils.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" namespace generator { diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index bcd50b8a2a..e488f15969 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -9,7 +9,7 @@ #include "geometry/mercator.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cstdint> @@ -233,7 +233,7 @@ namespace ftype { Classificator const & c = classif(); - my::StringIL arr[] = + base::StringIL arr[] = { {"entrance"}, {"highway"}, {"building", "address"}, {"hwtag", "oneway"}, {"hwtag", "private"}, @@ -439,13 +439,13 @@ namespace ftype if (!isHighway || (surface.empty() && smoothness.empty())) return string(); - static my::StringIL pavedSurfaces = {"paved", "asphalt", "cobblestone", "cobblestone:flattened", - "sett", "concrete", "concrete:lanes", "concrete:plates", - "paving_stones", "metal", "wood"}; - static my::StringIL badSurfaces = {"cobblestone", "sett", "metal", "wood", "grass", "gravel", - "mud", "sand", "snow", "woodchips"}; - static my::StringIL badSmoothness = {"bad", "very_bad", "horrible", "very_horrible", "impassable", - "robust_wheels", "high_clearance", "off_road_wheels", "rough"}; + static base::StringIL pavedSurfaces = {"paved", "asphalt", "cobblestone", "cobblestone:flattened", + "sett", "concrete", "concrete:lanes", "concrete:plates", + "paving_stones", "metal", "wood"}; + static base::StringIL badSurfaces = {"cobblestone", "sett", "metal", "wood", "grass", "gravel", + "mud", "sand", "snow", "woodchips"}; + static base::StringIL badSmoothness = {"bad", "very_bad", "horrible", "very_horrible", "impassable", + "robust_wheels", "high_clearance", "off_road_wheels", "rough"}; bool isPaved = false; bool isGood = true; diff --git a/generator/osm_o5m_source.hpp b/generator/osm_o5m_source.hpp index 5966ede0de..3136712e05 100644 --- a/generator/osm_o5m_source.hpp +++ b/generator/osm_o5m_source.hpp @@ -141,7 +141,7 @@ public: case EntityType::Sync: s << "O5M_CMD_SYNC"; case EntityType::Jump: s << "O5M_CMD_JUMP"; case EntityType::Reset: s << "O5M_CMD_RESET"; - default: return s << "Unknown command: " << std::hex << my::Key(type); + default: return s << "Unknown command: " << std::hex << base::Key(type); } return s; } diff --git a/generator/polygonizer.hpp b/generator/polygonizer.hpp index 43427b3b5d..c6e84f8719 100644 --- a/generator/polygonizer.hpp +++ b/generator/polygonizer.hpp @@ -73,7 +73,7 @@ namespace feature ~Polygonizer() { Finish(); - for_each(m_Buckets.begin(), m_Buckets.end(), DeleteFunctor()); + for_each(m_Buckets.begin(), m_Buckets.end(), base::DeleteFunctor()); } struct PointChecker diff --git a/generator/restaurants_info/restaurants_info.cpp b/generator/restaurants_info/restaurants_info.cpp index bcdf486389..93a8133b2c 100644 --- a/generator/restaurants_info/restaurants_info.cpp +++ b/generator/restaurants_info/restaurants_info.cpp @@ -10,7 +10,7 @@ #include "geometry/mercator.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cstdint> diff --git a/generator/restriction_collector.cpp b/generator/restriction_collector.cpp index 1a57fda7e0..f55556534e 100644 --- a/generator/restriction_collector.cpp +++ b/generator/restriction_collector.cpp @@ -55,7 +55,7 @@ RestrictionCollector::RestrictionCollector(std::string const & restrictionPath, } clean.release(); - my::SortUnique(m_restrictions); + base::SortUnique(m_restrictions); if (!IsValid()) LOG(LERROR, ("Some restrictions are not valid.")); diff --git a/generator/restriction_generator.cpp b/generator/restriction_generator.cpp index f94a727cf9..7f7d01178d 100644 --- a/generator/restriction_generator.cpp +++ b/generator/restriction_generator.cpp @@ -38,7 +38,7 @@ bool BuildRoadRestrictions(std::string const & mwmPath, std::string const & rest auto const firstOnlyIt = std::lower_bound(restrictions.cbegin(), restrictions.cend(), Restriction(Restriction::Type::Only, {} /* links */), - my::LessBy(&Restriction::m_type)); + base::LessBy(&Restriction::m_type)); RestrictionHeader header; header.m_noRestrictionCount = base::checked_cast<uint32_t>(std::distance(restrictions.cbegin(), firstOnlyIt)); diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index f994de3bae..83678d2166 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -32,7 +32,7 @@ #include "base/assert.hpp" #include "base/logging.hpp" #include "base/scope_guard.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "base/timer.hpp" @@ -69,7 +69,7 @@ public: continue; tokens.clear(); - strings::Tokenize(line, ":,", MakeBackInsertFunctor(tokens)); + strings::Tokenize(line, ":,", base::MakeBackInsertFunctor(tokens)); if (tokens.size() > 1) { @@ -162,7 +162,7 @@ struct FeatureNameInserter // split input string on tokens search::QueryTokens tokens; - SplitUniString(uniName, MakeBackInsertFunctor(tokens), search::Delimiters()); + SplitUniString(uniName, base::MakeBackInsertFunctor(tokens), search::Delimiters()); // add synonyms for input native string if (m_synonyms) @@ -274,7 +274,7 @@ public: // See OSM TagInfo or Wiki about modern postcodes format. The // mean number of tokens is less than two. buffer_vector<strings::UniString, 2> tokens; - SplitUniString(NormalizeAndSimplifyString(postcode), MakeBackInsertFunctor(tokens), + SplitUniString(NormalizeAndSimplifyString(postcode), base::MakeBackInsertFunctor(tokens), Delimiters()); for (auto const & token : tokens) inserter.AddToken(kPostcodesLang, token); diff --git a/generator/sponsored_dataset_inl.hpp b/generator/sponsored_dataset_inl.hpp index 891b4a0715..2190062c1b 100644 --- a/generator/sponsored_dataset_inl.hpp +++ b/generator/sponsored_dataset_inl.hpp @@ -10,7 +10,7 @@ #include "geometry/mercator.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" namespace generator diff --git a/generator/tag_admixer.hpp b/generator/tag_admixer.hpp index 29ee2e5326..eb5e254f72 100644 --- a/generator/tag_admixer.hpp +++ b/generator/tag_admixer.hpp @@ -3,7 +3,7 @@ #include "generator/osm_element.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <fstream> diff --git a/generator/unpack_mwm.cpp b/generator/unpack_mwm.cpp index 6d1b8aebfe..c8ed52aa49 100644 --- a/generator/unpack_mwm.cpp +++ b/generator/unpack_mwm.cpp @@ -5,19 +5,20 @@ #include "coding/read_write_utils.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <vector> +using namespace std; -void UnpackMwm(std::string const & filePath) +void UnpackMwm(string const & filePath) { LOG(LINFO, ("Unpacking mwm sections...")); FilesContainerR container(filePath); - std::vector<std::string> tags; - container.ForEachTag(MakeBackInsertFunctor<std::vector<std::string> >(tags)); + vector<string> tags; + container.ForEachTag(base::MakeBackInsertFunctor<vector<string>>(tags)); for (size_t i = 0; i < tags.size(); ++i) { @@ -32,7 +33,7 @@ void UnpackMwm(std::string const & filePath) LOG(LINFO, ("Unpacking done.")); } -void DeleteSection(std::string const & filePath, std::string const & tag) +void DeleteSection(string const & filePath, string const & tag) { FilesContainerW(filePath, FileWriter::OP_WRITE_EXISTING).DeleteSection(tag); } diff --git a/geocoder/geocoder_tests/geocoder_tests.cpp b/geocoder/geocoder_tests/geocoder_tests.cpp index 81e379635e..2d7535b562 100644 --- a/geocoder/geocoder_tests/geocoder_tests.cpp +++ b/geocoder/geocoder_tests/geocoder_tests.cpp @@ -42,8 +42,8 @@ void TestGeocoder(Geocoder & geocoder, string const & query, vector<Result> && e vector<Result> actual; geocoder.ProcessQuery(query, actual); TEST_EQUAL(actual.size(), expected.size(), (actual, expected)); - sort(actual.begin(), actual.end(), my::LessBy(&Result::m_osmId)); - sort(expected.begin(), expected.end(), my::LessBy(&Result::m_osmId)); + sort(actual.begin(), actual.end(), base::LessBy(&Result::m_osmId)); + sort(expected.begin(), expected.end(), base::LessBy(&Result::m_osmId)); for (size_t i = 0; i < actual.size(); ++i) { TEST_EQUAL(actual[i].m_osmId, expected[i].m_osmId, ()); diff --git a/geometry/convex_hull.cpp b/geometry/convex_hull.cpp index 4ba27dffdd..0daef2b979 100644 --- a/geometry/convex_hull.cpp +++ b/geometry/convex_hull.cpp @@ -33,7 +33,7 @@ bool IsContinuedBy(vector<PointD> const & hull, PointD const & p, double eps) vector<PointD> BuildConvexHull(vector<PointD> points, double eps) { - my::SortUnique(points); + base::SortUnique(points); auto const n = points.size(); diff --git a/geometry/covering.hpp b/geometry/covering.hpp index 5ffeb9a937..110b51432c 100644 --- a/geometry/covering.hpp +++ b/geometry/covering.hpp @@ -7,7 +7,7 @@ #include "base/base.hpp" #include "base/logging.hpp" #include "base/set_operations.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/algorithm.hpp" #include "std/array.hpp" @@ -111,32 +111,34 @@ public: private: void SimplifyLevel(int level) { - map<CellId, uint32_t, LessLevelOrder> parentCellCounts; - typedef typename vector<CellId>::const_iterator ConstIteartor; - for (ConstIteartor it = m_Covering[level].begin(); it != m_Covering[level].end(); ++it) + std::map<CellId, uint32_t, LessLevelOrder> parentCellCounts; + using ConstIterator = typename vector<CellId>::const_iterator; + for (ConstIterator it = m_Covering[level].begin(); it != m_Covering[level].end(); ++it) ++parentCellCounts[it->Parent()]; - vector<CellId> parentCells, childCells; - for (ConstIteartor it = m_Covering[level].begin(); it != m_Covering[level].end(); ++it) + vector<CellId> parentCells; + vector<CellId> childCells; + for (ConstIterator it = m_Covering[level].begin(); it != m_Covering[level].end(); ++it) { if (parentCellCounts[it->Parent()] > 1) parentCells.push_back(it->Parent()); else childCells.push_back(*it); } - ASSERT(IsSorted(parentCells.begin(), parentCells.end(), LessLevelOrder()), (parentCells)); - ASSERT(IsSorted(childCells.begin(), childCells.end(), LessLevelOrder()), (childCells)); + ASSERT(std::is_sorted(parentCells.begin(), parentCells.end(), LessLevelOrder()), (parentCells)); + ASSERT(std::is_sorted(childCells.begin(), childCells.end(), LessLevelOrder()), (childCells)); m_Covering[level].swap(childCells); - parentCells.erase(unique(parentCells.begin(), parentCells.end()), parentCells.end()); + parentCells.erase(std::unique(parentCells.begin(), parentCells.end()), parentCells.end()); AppendToVector(m_Covering[level - 1], parentCells); } static void AppendToVector(vector<CellId> & a, vector<CellId> const & b) { - ASSERT(IsSortedAndUnique(a.begin(), a.end(), LessLevelOrder()), (a)); - ASSERT(IsSortedAndUnique(b.begin(), b.end(), LessLevelOrder()), (b)); - vector<CellId> merged; - set_union(a.begin(), a.end(), b.begin(), b.end(), back_inserter(merged), LessLevelOrder()); + ASSERT(base::IsSortedAndUnique(a.begin(), a.end(), LessLevelOrder()), (a)); + ASSERT(base::IsSortedAndUnique(b.begin(), b.end(), LessLevelOrder()), (b)); + std::vector<CellId> merged; + std::set_union(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(merged), + LessLevelOrder()); a.swap(merged); } @@ -171,8 +173,8 @@ private: for (int level = 0; level < CellId::DEPTH_LEVELS; ++level) { vector<CellId> & covering = m_Covering[level]; - ASSERT(IsSorted(covering.begin(), covering.end(), LessLevelOrder()), (covering)); - covering.erase(unique(covering.begin(), covering.end()), covering.end()); + ASSERT(std::is_sorted(covering.begin(), covering.end(), LessLevelOrder()), (covering)); + covering.erase(std::unique(covering.begin(), covering.end()), covering.end()); } } @@ -198,16 +200,18 @@ private: for (int childLevel = parentLevel + 1; childLevel < static_cast<int>(m_Covering.size()); ++childLevel) { - vector<CellId> substracted; + std::vector<CellId> subtracted; CompareCellsAtLevel<LessLevelOrder> comparator(parentLevel); - ASSERT(IsSorted(m_Covering[childLevel].begin(), m_Covering[childLevel].end(), comparator), + ASSERT(std::is_sorted(m_Covering[childLevel].begin(), m_Covering[childLevel].end(), + comparator), (m_Covering[childLevel])); - ASSERT(IsSorted(m_Covering[parentLevel].begin(), m_Covering[parentLevel].end(), comparator), + ASSERT(std::is_sorted(m_Covering[parentLevel].begin(), m_Covering[parentLevel].end(), + comparator), (m_Covering[parentLevel])); SetDifferenceUnlimited(m_Covering[childLevel].begin(), m_Covering[childLevel].end(), m_Covering[parentLevel].begin(), m_Covering[parentLevel].end(), - back_inserter(substracted), comparator); - m_Covering[childLevel].swap(substracted); + std::back_inserter(subtracted), comparator); + m_Covering[childLevel].swap(subtracted); } } } @@ -280,4 +284,4 @@ private: array<vector<CellId>, CellId::DEPTH_LEVELS> m_Covering; // Covering by level. size_t m_Size; }; -} +} // namespace covering diff --git a/geometry/geometry_tests/covering_test.cpp b/geometry/geometry_tests/covering_test.cpp index e1164efabf..a3803560ce 100644 --- a/geometry/geometry_tests/covering_test.cpp +++ b/geometry/geometry_tests/covering_test.cpp @@ -1,15 +1,15 @@ #include "testing/testing.hpp" + #include "geometry/cellid.hpp" #include "geometry/covering.hpp" #include "geometry/covering_utils.hpp" #include "geometry/point2d.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" // TODO: Add covering unit tests here. - -typedef m2::CellId<5> CellId; +using CellId = m2::CellId<5>; UNIT_TEST(CoverTriangle_Simple) { diff --git a/geometry/geometry_tests/nearby_points_sweeper_test.cpp b/geometry/geometry_tests/nearby_points_sweeper_test.cpp index 4e84963fb2..187a286f5b 100644 --- a/geometry/geometry_tests/nearby_points_sweeper_test.cpp +++ b/geometry/geometry_tests/nearby_points_sweeper_test.cpp @@ -3,7 +3,7 @@ #include "geometry/nearby_points_sweeper.hpp" #include "geometry/point2d.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <set> #include <utility> @@ -30,7 +30,7 @@ UNIT_TEST(NearbyPointsSweeper_Smoke) TIndexSet expected = {0}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -48,7 +48,7 @@ UNIT_TEST(NearbyPointsSweeper_Smoke) TIndexSet expected = {0, 2, 5}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -62,7 +62,7 @@ UNIT_TEST(NearbyPointsSweeper_Smoke) TIndexSet expected = {0, 2, 5}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -80,7 +80,7 @@ UNIT_TEST(NearbyPointsSweeper_Smoke) TIndexSet expected = {0, 2, 3}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -106,7 +106,7 @@ UNIT_TEST(NearbyPointsSweeper_CornerCases) } TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -118,7 +118,7 @@ UNIT_TEST(NearbyPointsSweeper_CornerCases) TIndexSet expected = {0}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -134,7 +134,7 @@ UNIT_TEST(NearbyPointsSweeper_Priority) TIndexSet expected = {9}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -148,7 +148,7 @@ UNIT_TEST(NearbyPointsSweeper_Priority) TIndexSet expected = {1, 3}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } @@ -163,7 +163,7 @@ UNIT_TEST(NearbyPointsSweeper_Priority) TIndexSet expected = {1, 3}; TIndexSet actual; - sweeper.Sweep(MakeInsertFunctor(actual)); + sweeper.Sweep(base::MakeInsertFunctor(actual)); TEST_EQUAL(expected, actual, ()); } diff --git a/geometry/geometry_tests/polygon_test.cpp b/geometry/geometry_tests/polygon_test.cpp index 43160772fd..11b1aed991 100644 --- a/geometry/geometry_tests/polygon_test.cpp +++ b/geometry/geometry_tests/polygon_test.cpp @@ -29,9 +29,9 @@ void TestFindStrip(P const * beg, size_t n) TEST_LESS(i, n, ()); vector<size_t> test; - MakeSingleStripFromIndex(i, n, MakeBackInsertFunctor(test)); + MakeSingleStripFromIndex(i, n, base::MakeBackInsertFunctor(test)); - my::SortUnique(test); + base::SortUnique(test); TEST_EQUAL(test.size(), n, ()); } diff --git a/geometry/geometry_tests/simplification_test.cpp b/geometry/geometry_tests/simplification_test.cpp index be841051a9..dbff12a085 100644 --- a/geometry/geometry_tests/simplification_test.cpp +++ b/geometry/geometry_tests/simplification_test.cpp @@ -10,7 +10,7 @@ #include "base/logging.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <cstdint> #include <limits> @@ -22,7 +22,7 @@ namespace { using P = m2::PointD; using DistanceFn = m2::SquaredDistanceFromSegmentToPoint<P>; -using PointOutput = BackInsertFunctor<vector<m2::PointD>>; +using PointOutput = base::BackInsertFunctor<vector<m2::PointD>>; using SimplifyFn = void (*)(m2::PointD const *, m2::PointD const *, double, DistanceFn, PointOutput); @@ -40,7 +40,7 @@ void TestSimplificationSmoke(SimplifyFn simplifyFn) m2::PointD const points[] = {P(0.0, 1.0), P(2.2, 3.6), P(3.2, 3.6)}; double const epsilon = 0.1; vector<m2::PointD> result, expectedResult(points, points + 3); - simplifyFn(points, points + 3, epsilon, DistanceFn(), MakeBackInsertFunctor(result)); + simplifyFn(points, points + 3, epsilon, DistanceFn(), base::MakeBackInsertFunctor(result)); TEST_EQUAL(result, expectedResult, (epsilon)); } @@ -50,7 +50,7 @@ void TestSimplificationOfLine(SimplifyFn simplifyFn) for (double epsilon = numeric_limits<double>::denorm_min(); epsilon < 1000; epsilon *= 2) { vector<m2::PointD> result, expectedResult(points, points + 2); - simplifyFn(points, points + 2, epsilon, DistanceFn(), MakeBackInsertFunctor(result)); + simplifyFn(points, points + 2, epsilon, DistanceFn(), base::MakeBackInsertFunctor(result)); TEST_EQUAL(result, expectedResult, (epsilon)); } } @@ -60,7 +60,7 @@ void TestSimplificationOfPoly(m2::PointD const * points, size_t count, SimplifyF for (double epsilon = 0.00001; epsilon < 0.11; epsilon *= 10) { vector<m2::PointD> result; - simplifyFn(points, points + count, epsilon, DistanceFn(), MakeBackInsertFunctor(result)); + simplifyFn(points, points + count, epsilon, DistanceFn(), base::MakeBackInsertFunctor(result)); // LOG(LINFO, ("eps:", epsilon, "size:", result.size())); TEST_GREATER(result.size(), 1, ()); diff --git a/geometry/geometry_tests/tree_test.cpp b/geometry/geometry_tests/tree_test.cpp index 1495663049..5cf8ff06f8 100644 --- a/geometry/geometry_tests/tree_test.cpp +++ b/geometry/geometry_tests/tree_test.cpp @@ -40,12 +40,12 @@ UNIT_TEST(Tree4D_Smoke) theTree.ReplaceAllInRect(arr[i], &RTrue<R>); vector<R> test; - theTree.ForEach(MakeBackInsertFunctor(test)); + theTree.ForEach(base::MakeBackInsertFunctor(test)); TEST_EQUAL(3, test.size(), ()); test.clear(); R const searchR(1.5, 1.5, 1.5, 1.5); - theTree.ForEachInRect(searchR, MakeBackInsertFunctor(test)); + theTree.ForEachInRect(searchR, base::MakeBackInsertFunctor(test)); TEST_EQUAL(1, test.size(), ()); TEST_EQUAL(test[0], arr[1], ()); @@ -53,12 +53,12 @@ UNIT_TEST(Tree4D_Smoke) theTree.ReplaceAllInRect(replaceR, &RTrue<R>); test.clear(); - theTree.ForEach(MakeBackInsertFunctor(test)); + theTree.ForEach(base::MakeBackInsertFunctor(test)); TEST_EQUAL(1, test.size(), ()); TEST_EQUAL(test[0], replaceR, ()); test.clear(); - theTree.ForEachInRect(searchR, MakeBackInsertFunctor(test)); + theTree.ForEachInRect(searchR, base::MakeBackInsertFunctor(test)); TEST_EQUAL(1, test.size(), ()); } @@ -84,7 +84,7 @@ UNIT_TEST(Tree4D_ReplaceAllInRect) } vector<R> test; - theTree.ForEach(MakeBackInsertFunctor(test)); + theTree.ForEach(base::MakeBackInsertFunctor(test)); TEST_EQUAL(ARRAY_SIZE(arr), test.size(), ()); for (size_t i = 0; i < test.size(); ++i) @@ -101,7 +101,7 @@ void CheckInRect(R const * arr, size_t count, R const & searchR, size_t expected theTree.Add(arr[i], arr[i]); vector<R> test; - theTree.ForEachInRect(searchR, MakeBackInsertFunctor(test)); + theTree.ForEachInRect(searchR, base::MakeBackInsertFunctor(test)); TEST_EQUAL(test.size(), expected, ()); } @@ -151,14 +151,14 @@ UNIT_TEST(Tree4D_ReplaceEqual) theTree.ReplaceEqualInRect(arr[i], equal_to<T>(), &RTrue<T>); vector<T> test; - theTree.ForEach(MakeBackInsertFunctor(test)); + theTree.ForEach(base::MakeBackInsertFunctor(test)); TEST_EQUAL(3, test.size(), ()); // 2. theTree.ReplaceEqualInRect(T(0, 0, 3, 3, 2), equal_to<T>(), &RFalse<T>); test.clear(); - theTree.ForEach(MakeBackInsertFunctor(test)); + theTree.ForEach(base::MakeBackInsertFunctor(test)); TEST_EQUAL(3, test.size(), ()); auto i = find(test.begin(), test.end(), T(1, 1, 2, 2, 2)); @@ -168,7 +168,7 @@ UNIT_TEST(Tree4D_ReplaceEqual) theTree.ReplaceEqualInRect(T(0, 0, 3, 3, 2), equal_to<T>(), &RTrue<T>); test.clear(); - theTree.ForEach(MakeBackInsertFunctor(test)); + theTree.ForEach(base::MakeBackInsertFunctor(test)); TEST_EQUAL(3, test.size(), ()); i = find(test.begin(), test.end(), T(1, 1, 2, 2, 2)); diff --git a/geometry/polygon.hpp b/geometry/polygon.hpp index 9ddca7427a..b4d91722c5 100644 --- a/geometry/polygon.hpp +++ b/geometry/polygon.hpp @@ -5,7 +5,7 @@ #include "base/assert.hpp" #include "base/base.hpp" #include "base/math.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/iterator.hpp" #include "std/limits.hpp" @@ -72,8 +72,8 @@ template <typename IterT> bool IsPolygonCCW(IterT beg, IterT end) } } - double cp = m2::robust::OrientedS(*PrevIterInCycle(iRes, beg, end), *iRes, - *NextIterInCycle(iRes, beg, end)); + double cp = m2::robust::OrientedS(*base::PrevIterInCycle(iRes, beg, end), *iRes, + *base::NextIterInCycle(iRes, beg, end)); if (cp != 0.0) return (cp > 0.0); @@ -88,8 +88,8 @@ template <typename IterT> bool IsPolygonCCW(IterT beg, IterT end) } } - IterT iPrev = PrevIterInCycle(iRes, beg, end); - IterT iNext = NextIterInCycle(iRes, beg, end); + IterT iPrev = base::PrevIterInCycle(iRes, beg, end); + IterT iNext = base::NextIterInCycle(iRes, beg, end); cp = m2::robust::OrientedS(*iPrev, *iRes, *iNext); ASSERT_NOT_EQUAL(cp, 0.0, (*iPrev, *iRes, *iNext)); @@ -105,15 +105,15 @@ bool IsDiagonalVisible(IterT beg, IterT end, IterT i0, IterT i1) ASSERT ( TestPolygonPreconditions(beg, end), () ); ASSERT ( i0 != i1, () ); - IterT const prev = PrevIterInCycle(i0, beg, end); - IterT const next = NextIterInCycle(i0, beg, end); + IterT const prev = base::PrevIterInCycle(i0, beg, end); + IterT const next = base::NextIterInCycle(i0, beg, end); if (prev == i1 || next == i1) return true; if (!m2::robust::IsSegmentInCone(*i0, *i1, *prev, *next)) return false; - for (IterT j0 = beg, j1 = PrevIterInCycle(beg, beg, end); j0 != end; j1 = j0++) + for (IterT j0 = beg, j1 = base::PrevIterInCycle(beg, beg, end); j0 != end; j1 = j0++) if (j0 != i0 && j0 != i1 && j1 != i0 && j1 != i1 && m2::robust::SegmentsIntersect(*i0, *i1, *j0, *j1)) return false; @@ -176,7 +176,7 @@ template <class TIter> double GetPolygonArea(TIter beg, TIter end) TIter curr = beg; while (curr != end) { - TIter next = NextIterInCycle(curr, beg, end); + TIter next = base::NextIterInCycle(curr, beg, end); area += ((*curr).x * (*next).y - (*curr).y * (*next).x); ++curr; } diff --git a/geometry/robust_orientation.hpp b/geometry/robust_orientation.hpp index 5417ff73c1..d4b86c96f2 100644 --- a/geometry/robust_orientation.hpp +++ b/geometry/robust_orientation.hpp @@ -2,7 +2,7 @@ #include "geometry/point2d.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <iterator> @@ -51,8 +51,8 @@ bool CheckPolygonSelfIntersections(Iter beg, Iter end) if (std::distance(i, j) <= 1 || (i == beg && j == last)) continue; - Iter ii = NextIterInCycle(i, beg, end); - Iter jj = NextIterInCycle(j, beg, end); + Iter ii = base::NextIterInCycle(i, beg, end); + Iter jj = base::NextIterInCycle(j, beg, end); PointD a = *i, b = *ii, c = *j, d = *jj; // check for rect intersection @@ -78,13 +78,13 @@ bool CheckPolygonSelfIntersections(Iter beg, Iter end) if (s1 == 0.0 && IsInSection(a, b, c)) { - PointD const prev = *PrevIterInCycle(j, beg, end); + PointD const prev = *base::PrevIterInCycle(j, beg, end); PointD test[] = {a, b}; if (a == c) - test[0] = *PrevIterInCycle(i, beg, end); + test[0] = *base::PrevIterInCycle(i, beg, end); if (b == c) - test[1] = *NextIterInCycle(ii, beg, end); + test[1] = *base::NextIterInCycle(ii, beg, end); if (IsSegmentInCone(c, test[0], prev, d) == IsSegmentInCone(c, test[1], prev, d)) continue; @@ -92,13 +92,13 @@ bool CheckPolygonSelfIntersections(Iter beg, Iter end) if (s2 == 0.0 && IsInSection(a, b, d)) { - PointD const next = *NextIterInCycle(jj, beg, end); + PointD const next = *base::NextIterInCycle(jj, beg, end); PointD test[] = {a, b}; if (a == d) - test[0] = *PrevIterInCycle(i, beg, end); + test[0] = *base::PrevIterInCycle(i, beg, end); if (b == d) - test[1] = *NextIterInCycle(ii, beg, end); + test[1] = *base::NextIterInCycle(ii, beg, end); if (IsSegmentInCone(d, test[0], c, next) == IsSegmentInCone(d, test[1], c, next)) continue; @@ -106,13 +106,13 @@ bool CheckPolygonSelfIntersections(Iter beg, Iter end) if (s3 == 0.0 && IsInSection(c, d, a)) { - PointD const prev = *PrevIterInCycle(i, beg, end); + PointD const prev = *base::PrevIterInCycle(i, beg, end); PointD test[] = {c, d}; if (c == a) - test[0] = *PrevIterInCycle(j, beg, end); + test[0] = *base::PrevIterInCycle(j, beg, end); if (d == a) - test[1] = *NextIterInCycle(jj, beg, end); + test[1] = *base::NextIterInCycle(jj, beg, end); if (IsSegmentInCone(a, test[0], prev, b) == IsSegmentInCone(a, test[1], prev, b)) continue; @@ -120,13 +120,13 @@ bool CheckPolygonSelfIntersections(Iter beg, Iter end) if (s4 == 0.0 && IsInSection(c, d, b)) { - PointD const next = *NextIterInCycle(ii, beg, end); + PointD const next = *base::NextIterInCycle(ii, beg, end); PointD test[] = {c, d}; if (c == b) - test[0] = *PrevIterInCycle(j, beg, end); + test[0] = *base::PrevIterInCycle(j, beg, end); if (d == b) - test[1] = *NextIterInCycle(jj, beg, end); + test[1] = *base::NextIterInCycle(jj, beg, end); if (IsSegmentInCone(b, test[0], a, next) == IsSegmentInCone(b, test[1], a, next)) continue; diff --git a/geometry/simplification.hpp b/geometry/simplification.hpp index f61904f4a9..58f18cb30c 100644 --- a/geometry/simplification.hpp +++ b/geometry/simplification.hpp @@ -3,8 +3,8 @@ #include "geometry/point2d.hpp" #include "base/base.hpp" -#include "base/stl_add.hpp" #include "base/logging.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <cstdint> diff --git a/geometry/tree4d.hpp b/geometry/tree4d.hpp index 95e7669f7b..43efb33fcc 100644 --- a/geometry/tree4d.hpp +++ b/geometry/tree4d.hpp @@ -4,7 +4,7 @@ #include "geometry/rect2d.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <sstream> #include <string> diff --git a/indexer/categories_holder.cpp b/indexer/categories_holder.cpp index 5028e823f4..9156f6c0df 100644 --- a/indexer/categories_holder.cpp +++ b/indexer/categories_holder.cpp @@ -7,7 +7,7 @@ #include "coding/reader_streambuf.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" using namespace std; @@ -128,7 +128,7 @@ void ProcessCategory(string const & line, vector<string> & groups, vector<uint32 // Split category to subcategories for classificator. vector<string> v; - strings::Tokenize(line, "-", MakeBackInsertFunctor(v)); + strings::Tokenize(line, "-", base::MakeBackInsertFunctor(v)); // Get classificator type. uint32_t const type = classif().GetTypeByPathSafe(v); @@ -217,7 +217,7 @@ void CategoriesHolder::AddCategory(Category & cat, vector<uint32_t> & types) auto const uniName = search::NormalizeAndSimplifyString(synonym.m_name); vector<String> tokens; - SplitUniString(uniName, MakeBackInsertFunctor(tokens), search::Delimiters()); + SplitUniString(uniName, base::MakeBackInsertFunctor(tokens), search::Delimiters()); for (auto const & token : tokens) { diff --git a/indexer/categories_index.cpp b/indexer/categories_index.cpp index 472215a544..e8497bf53b 100644 --- a/indexer/categories_index.cpp +++ b/indexer/categories_index.cpp @@ -3,7 +3,6 @@ #include "search_string_utils.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" #include "base/stl_helpers.hpp" #include "base/string_utils.hpp" @@ -33,7 +32,7 @@ template <typename TF> void ForEachToken(string const & s, TF && fn) { vector<strings::UniString> tokens; - SplitUniString(search::NormalizeAndSimplifyString(s), MakeBackInsertFunctor(tokens), + SplitUniString(search::NormalizeAndSimplifyString(s), base::MakeBackInsertFunctor(tokens), search::Delimiters()); for (auto const & token : tokens) fn(strings::ToUtf8(token)); @@ -96,7 +95,7 @@ void CategoriesIndex::GetCategories(string const & query, vector<Category> & res { vector<uint32_t> types; GetAssociatedTypes(query, types); - my::SortUnique(types); + base::SortUnique(types); m_catHolder->ForEachTypeAndCategory([&](uint32_t type, Category const & cat) { if (binary_search(types.begin(), types.end(), type)) diff --git a/indexer/cuisines.cpp b/indexer/cuisines.cpp index 1662bb7c47..c378392cea 100644 --- a/indexer/cuisines.cpp +++ b/indexer/cuisines.cpp @@ -1,6 +1,6 @@ #include "indexer/cuisines.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" using namespace std; @@ -32,7 +32,7 @@ string TranslateImpl(platform::TGetTextByIdPtr const & ptr, string const & key) void Cuisines::Parse(string const & osmRawCuisinesTagValue, vector<string> & outCuisines) { - strings::Tokenize(osmRawCuisinesTagValue, ";", MakeBackInsertFunctor(outCuisines)); + strings::Tokenize(osmRawCuisinesTagValue, ";", base::MakeBackInsertFunctor(outCuisines)); } void Cuisines::ParseAndLocalize(string const & osmRawCuisinesTagValue, vector<string> & outCuisines, diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index 9338f2585b..600ec82662 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -8,7 +8,7 @@ #include "base/assert.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <algorithm> @@ -46,7 +46,7 @@ TypesHolder::TypesHolder(FeatureType & f) : m_size(0), m_geoType(f.GetFeatureTyp void TypesHolder::Remove(uint32_t type) { - UNUSED_VALUE(RemoveIf(EqualFunctor<uint32_t>(type))); + UNUSED_VALUE(RemoveIf(base::EqualFunctor<uint32_t>(type))); } bool TypesHolder::Equals(TypesHolder const & other) const @@ -174,7 +174,7 @@ void TypesHolder::SortBySpec() // Put "very common" types to the end of possible PP-description types. static UselessTypesChecker checker; - UNUSED_VALUE(RemoveIfKeepValid(begin(), end(), [](uint32_t t) { return checker(t); })); + UNUSED_VALUE(base::RemoveIfKeepValid(begin(), end(), [](uint32_t t) { return checker(t); })); } vector<string> TypesHolder::ToObjectNames() const @@ -475,7 +475,7 @@ bool FeatureParams::FinishAddingTypes() if (type != boundary) { // Find all equal types (2-arity). - auto j = RemoveIfKeepValid(m_types.begin() + i + 1, m_types.end(), [type] (uint32_t t) + auto j = base::RemoveIfKeepValid(m_types.begin() + i + 1, m_types.end(), [type] (uint32_t t) { ftype::TruncValue(t, 2); return (type == t); diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 8bad15526e..d6437cf3af 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -6,7 +6,7 @@ #include "base/assert.hpp" #include "base/buffer_vector.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cmath> @@ -488,7 +488,7 @@ uint64_t GetPopulationByRadius(double r) return my::rounds(pow(r / 550.0, 3.6)); } -bool IsTypeConformed(uint32_t type, my::StringIL const & path) +bool IsTypeConformed(uint32_t type, base::StringIL const & path) { ClassifObject const * p = classif().GetRoot(); ASSERT(p, ()); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index c150de5ddf..c90952784c 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -189,7 +189,7 @@ public: using UnderlyingType = std::underlying_type_t<Type>; - static_assert(my::Key(Type::Count) <= CHAR_BIT * sizeof(unsigned), + static_assert(base::Key(Type::Count) <= CHAR_BIT * sizeof(unsigned), "Too many types of hotels"); static char const * GetHotelTypeTag(Type type); @@ -202,7 +202,7 @@ public: private: IsHotelChecker(); - std::array<std::pair<uint32_t, Type>, my::Key(Type::Count)> m_sortedTypes; + std::array<std::pair<uint32_t, Type>, base::Key(Type::Count)> m_sortedTypes; }; // WiFi is a type in classificator.txt, @@ -272,7 +272,7 @@ uint64_t GetPopulationByRadius(double r); /// feature types like "highway", "living_street", "bridge" and so on /// or *. * means any class. /// The root name ("world") is ignored -bool IsTypeConformed(uint32_t type, my::StringIL const & path); +bool IsTypeConformed(uint32_t type, base::StringIL const & path); // Highway class. The order is important. // The enum values follow from the biggest roads (Trunk) to the smallest ones (Service). diff --git a/indexer/indexer_tests/data_source_test.cpp b/indexer/indexer_tests/data_source_test.cpp index 87680c0142..c52f75046f 100644 --- a/indexer/indexer_tests/data_source_test.cpp +++ b/indexer/indexer_tests/data_source_test.cpp @@ -15,7 +15,7 @@ #include "base/logging.hpp" #include "base/macros.hpp" #include "base/scope_guard.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <string> diff --git a/indexer/indexer_tests/index_builder_test.cpp b/indexer/indexer_tests/index_builder_test.cpp index e1867a20aa..58230097db 100644 --- a/indexer/indexer_tests/index_builder_test.cpp +++ b/indexer/indexer_tests/index_builder_test.cpp @@ -13,8 +13,7 @@ #include "coding/file_container.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" - +#include "base/stl_helpers.hpp" UNIT_TEST(BuildIndexTest) { @@ -41,7 +40,7 @@ UNIT_TEST(BuildIndexTest) { FilesContainerW containerWriter(filePath); vector<string> tags; - originalContainer.ForEachTag(MakeBackInsertFunctor(tags)); + originalContainer.ForEachTag(base::MakeBackInsertFunctor(tags)); for (size_t i = 0; i < tags.size(); ++i) { if (tags[i] != INDEX_FILE_TAG) diff --git a/indexer/indexer_tests/interval_index_test.cpp b/indexer/indexer_tests/interval_index_test.cpp index af02d7c334..5df8e658c7 100644 --- a/indexer/indexer_tests/interval_index_test.cpp +++ b/indexer/indexer_tests/interval_index_test.cpp @@ -7,7 +7,7 @@ #include "coding/writer.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <utility> #include <vector> @@ -133,7 +133,7 @@ UNIT_TEST(IntervalIndex_Serialized) uint32_t expected [] = {0, 1, 2}; vector<uint32_t> values; TEST_EQUAL(index.KeyEnd(), 0x10000, ()); - index.ForEach(MakeBackInsertFunctor(values), 0, 0x10000); + index.ForEach(base::MakeBackInsertFunctor(values), 0, 0x10000); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } @@ -152,41 +152,41 @@ UNIT_TEST(IntervalIndex_Simple) { uint32_t expected [] = {0, 1, 2}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0ULL, index.KeyEnd()); + index.ForEach(base::MakeBackInsertFunctor(values), 0ULL, index.KeyEnd()); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } { uint32_t expected [] = {0, 1}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D201ULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D201ULL); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } { uint32_t expected [] = {0, 1}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0x0ULL, 0xA0B1C30000ULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0x0ULL, 0xA0B1C30000ULL); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } { uint32_t expected [] = {0}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D101ULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D101ULL); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } { uint32_t expected [] = {0}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D200ULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D200ULL); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } { vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D100ULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0xA0B1C2D100ULL, 0xA0B1C2D100ULL); TEST_EQUAL(values, vector<uint32_t>(), ()); } { vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0xA0B1000000ULL, 0xA0B1B20000ULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0xA0B1000000ULL, 0xA0B1B20000ULL); TEST_EQUAL(values, vector<uint32_t>(), ()); } } @@ -201,7 +201,7 @@ UNIT_TEST(IntervalIndex_Empty) IntervalIndex<MemReader, uint32_t> index(reader); { vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0ULL, 0xFFFFFFFFFFULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0ULL, 0xFFFFFFFFFFULL); TEST_EQUAL(values, vector<uint32_t>(), ()); } } @@ -221,7 +221,7 @@ UNIT_TEST(IntervalIndex_Simple2) { uint32_t expected [] = {0, 1, 2, 3}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0, 0xFFFFFFFFFFULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0, 0xFFFFFFFFFFULL); sort(values.begin(), values.end()); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } @@ -240,7 +240,7 @@ UNIT_TEST(IntervalIndex_Simple3) { uint32_t expected [] = {0, 1}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0, 0xFFFFULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0, 0xFFFFULL); sort(values.begin(), values.end()); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } @@ -259,7 +259,7 @@ UNIT_TEST(IntervalIndex_Simple4) { uint32_t expected [] = {0, 1}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0, 0xFFFFFFFFULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0, 0xFFFFFFFFULL); sort(values.begin(), values.end()); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } @@ -280,7 +280,7 @@ UNIT_TEST(IntervalIndex_Simple5) { uint32_t expected [] = {0, 1, 2, 3}; vector<uint32_t> values; - index.ForEach(MakeBackInsertFunctor(values), 0, 0xFFFFFFFFFFULL); + index.ForEach(base::MakeBackInsertFunctor(values), 0, 0xFFFFFFFFFFULL); sort(values.begin(), values.end()); TEST_EQUAL(values, vector<uint32_t>(expected, expected + ARRAY_SIZE(expected)), ()); } diff --git a/indexer/indexer_tests/postcodes_matcher_tests.cpp b/indexer/indexer_tests/postcodes_matcher_tests.cpp index 75042e7fdb..fcda954077 100644 --- a/indexer/indexer_tests/postcodes_matcher_tests.cpp +++ b/indexer/indexer_tests/postcodes_matcher_tests.cpp @@ -4,7 +4,7 @@ #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" using namespace strings; diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 32cde0bf9f..af655d89dc 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -158,7 +158,7 @@ std::vector<Props> MetadataToProps(std::vector<T> const & metadata) // Please add new cases when compiler issues an "unhandled switch case" warning here. } } - my::SortUnique(res); + base::SortUnique(res); return res; } } // namespace osm diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 45d7a562e4..8cdb0c77c1 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -8,7 +8,7 @@ #include "base/assert.hpp" #include "base/exception.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <exception> @@ -409,7 +409,7 @@ void MwmSet::ClearCache(MwmId const & id) { return (p.first == id); }; - ClearCacheImpl(RemoveIfKeepValid(m_cache.begin(), m_cache.end(), sameId), m_cache.end()); + ClearCacheImpl(base::RemoveIfKeepValid(m_cache.begin(), m_cache.end(), sameId), m_cache.end()); } // MwmValue ---------------------------------------------------------------------------------------- diff --git a/indexer/postcodes_matcher.cpp b/indexer/postcodes_matcher.cpp index 8b8b6cbce3..1cb630bad0 100644 --- a/indexer/postcodes_matcher.cpp +++ b/indexer/postcodes_matcher.cpp @@ -5,7 +5,7 @@ #include "base/logging.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <algorithm> @@ -76,7 +76,7 @@ private: void AddString(UniString const & s, search::Delimiters & delimiters) { vector<UniString> tokens; - SplitUniString(s, MakeBackInsertFunctor(tokens), delimiters); + SplitUniString(s, base::MakeBackInsertFunctor(tokens), delimiters); StringSlice slice(tokens); m_maxNumTokensInPostcode = max(m_maxNumTokensInPostcode, tokens.size()); diff --git a/indexer/search_string_utils.hpp b/indexer/search_string_utils.hpp index 22c049d517..77f261d61c 100644 --- a/indexer/search_string_utils.hpp +++ b/indexer/search_string_utils.hpp @@ -2,7 +2,7 @@ #include "indexer/search_delimiters.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cstdint> @@ -12,7 +12,6 @@ namespace search { - // This function should be used for all search strings normalization. // It does some magic text transformation which greatly helps us to improve our search. strings::UniString NormalizeAndSimplifyString(std::string const & s); @@ -27,13 +26,13 @@ void SplitUniString(strings::UniString const & uniS, Fn && f, Delims const & del template <typename Tokens, typename Delims> void NormalizeAndTokenizeString(std::string const & s, Tokens & tokens, Delims const & delims) { - SplitUniString(NormalizeAndSimplifyString(s), MakeBackInsertFunctor(tokens), delims); + SplitUniString(NormalizeAndSimplifyString(s), ::base::MakeBackInsertFunctor(tokens), delims); } template <typename Tokens> void NormalizeAndTokenizeString(std::string const & s, Tokens & tokens) { - SplitUniString(NormalizeAndSimplifyString(s), MakeBackInsertFunctor(tokens), + SplitUniString(NormalizeAndSimplifyString(s), ::base::MakeBackInsertFunctor(tokens), search::Delimiters()); } @@ -50,7 +49,7 @@ bool TokenizeStringAndCheckIfLastTokenIsPrefix(strings::UniString const & s, Tokens & tokens, Delims const & delims) { - SplitUniString(s, MakeBackInsertFunctor(tokens), delims); + SplitUniString(s, ::base::MakeBackInsertFunctor(tokens), delims); return !s.empty() && !delims(s.back()); } diff --git a/indexer/types_mapping.cpp b/indexer/types_mapping.cpp index 17da4bb15e..962a049ef5 100644 --- a/indexer/types_mapping.cpp +++ b/indexer/types_mapping.cpp @@ -1,8 +1,8 @@ #include "indexer/types_mapping.hpp" #include "indexer/classificator.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" -#include "base/stl_add.hpp" using namespace std; @@ -28,7 +28,7 @@ void IndexAndTypeMapping::Load(istream & s) if (!v.empty()) { path.clear(); - strings::Tokenize(v, "|", MakeBackInsertFunctor(path)); + strings::Tokenize(v, "|", base::MakeBackInsertFunctor(path)); Add(ind++, c.GetTypeByPath(path)); } diff --git a/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm b/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm index 2ce58c26ac..27bea56e19 100644 --- a/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm +++ b/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm @@ -167,14 +167,14 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result) [[MWMBookmarksManager manager] loopObservers:^(Observer observer) { if ([observer respondsToSelector:@selector(onSynchronizationFinished:)]) - [observer onSynchronizationFinished:static_cast<MWMSynchronizationResult>(my::Key(result))]; + [observer onSynchronizationFinished:static_cast<MWMSynchronizationResult>(base::Key(result))]; }]; }; auto onRestoreRequested = [](Cloud::RestoringRequestResult result, std::string const & deviceName, uint64_t backupTimestampInMs) { - auto const res = static_cast<MWMRestoringRequestResult>(my::Key(result)); + auto const res = static_cast<MWMRestoringRequestResult>(base::Key(result)); NSDate * date = nil; if (result == Cloud::RestoringRequestResult::BackupExists) diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index c1726635c9..81442a3a34 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -630,7 +630,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) { if (auto const price = data.hotelRawApproximatePricing) { - CHECK_LESS_OR_EQUAL(*price, my::Key(search_filter::Price::Three), ()); + CHECK_LESS_OR_EQUAL(*price, base::Key(search_filter::Price::Three), ()); params.m_price = static_cast<search_filter::Price>(*price); } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm index ebcdab362c..2217704879 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Preview/MWMPPPreviewLayoutHelper.mm @@ -187,7 +187,7 @@ std::array<Class, 9> const kPreviewCells = {{[_MWMPPPTitle class], using namespace place_page; auto tableView = self.tableView; auto const row = data.previewRows[indexPath.row]; - Class cls = kPreviewCells[my::Key(row)]; + Class cls = kPreviewCells[base::Key(row)]; auto * c = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]; switch(row) diff --git a/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm b/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm index 0cf77cebf9..a7b22301da 100644 --- a/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm +++ b/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm @@ -20,7 +20,7 @@ static uint8_t kAdultsCount = 2; static int8_t kAgeOfChild = 5; static NSString * const kHotelTypePattern = @"search_hotel_filter_%@"; -std::array<ftypes::IsHotelChecker::Type, my::Key(ftypes::IsHotelChecker::Type::Count)> const +std::array<ftypes::IsHotelChecker::Type, base::Key(ftypes::IsHotelChecker::Type::Count)> const kTypes = {{ftypes::IsHotelChecker::Type::Hotel, ftypes::IsHotelChecker::Type::Apartment, ftypes::IsHotelChecker::Type::CampSite, ftypes::IsHotelChecker::Type::Chalet, ftypes::IsHotelChecker::Type::GuestHouse, ftypes::IsHotelChecker::Type::Hostel, @@ -141,7 +141,7 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar { m_selectedTypes.emplace(params.m_type); [self.type.collectionView - selectItemAtIndexPath:[NSIndexPath indexPathForItem:my::Key(params.m_type) + selectItemAtIndexPath:[NSIndexPath indexPathForItem:base::Key(params.m_type) inSection:0] animated:NO scrollPosition:UICollectionViewScrollPositionNone]; @@ -398,7 +398,7 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return my::Key(Section::Count); + return base::Key(Section::Count); } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section diff --git a/kml/serdes.cpp b/kml/serdes.cpp index a5b2281d24..7f2c0c1527 100644 --- a/kml/serdes.cpp +++ b/kml/serdes.cpp @@ -317,7 +317,7 @@ void SaveCategoryExtendedData(KmlWriter::WriterWrapper & writer, CategoryData co void SaveCategoryData(KmlWriter::WriterWrapper & writer, CategoryData const & categoryData, std::string const & extendedServerId) { - for (uint8_t i = 0; i < my::Key(PredefinedColor::Count); ++i) + for (uint8_t i = 0; i < base::Key(PredefinedColor::Count); ++i) SaveStyle(writer, GetStyleForPredefinedColor(static_cast<PredefinedColor>(i))); // Use CDATA if we have special symbols in the name. diff --git a/kml/serdes.hpp b/kml/serdes.hpp index f18153bb4c..f30531f850 100644 --- a/kml/serdes.hpp +++ b/kml/serdes.hpp @@ -7,7 +7,7 @@ #include "coding/writer.hpp" #include "base/exception.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <chrono> #include <string> diff --git a/local_ads/campaign_serialization.cpp b/local_ads/campaign_serialization.cpp index 02e24b1a40..041c2df97a 100644 --- a/local_ads/campaign_serialization.cpp +++ b/local_ads/campaign_serialization.cpp @@ -7,7 +7,7 @@ #include "base/exception.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <climits> #include <cstdint> diff --git a/map/cloud.cpp b/map/cloud.cpp index f84e593688..8dda4fe597 100644 --- a/map/cloud.cpp +++ b/map/cloud.cpp @@ -503,7 +503,7 @@ void Cloud::UpdateIndex(bool indexExists) MarkModifiedImpl(path.second, true /* isOutdated */); // Erase disappeared files from index. - my::EraseIf(m_index.m_entries, [this](EntryPtr const & entity) { + base::EraseIf(m_index.m_entries, [this](EntryPtr const & entity) { return m_files.find(entity->m_name) == m_files.end(); }); diff --git a/map/framework.cpp b/map/framework.cpp index 7bc661b28d..f91091f029 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1505,7 +1505,7 @@ search::DisplayedCategories const & Framework::GetDisplayedCategories() { // Add Category modifiers here. //std::tuple<Modifier> modifiers(city); - //my::for_each_in_tuple(modifiers, [&](size_t, SponsoredCategoryModifier & modifier) + //base::for_each_in_tuple(modifiers, [&](size_t, SponsoredCategoryModifier & modifier) //{ // m_displayedCategories->Modify(modifier); //}); diff --git a/map/style_tests/classificator_tests.cpp b/map/style_tests/classificator_tests.cpp index 3552e95881..c0a875768a 100644 --- a/map/style_tests/classificator_tests.cpp +++ b/map/style_tests/classificator_tests.cpp @@ -9,7 +9,7 @@ #include "platform/platform.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" using namespace std; @@ -101,7 +101,7 @@ void ForEachObject(Classificator const & c, string const & name, EGeomType geomType, int rules) { vector<string> path; - strings::Tokenize(name, "-", MakeBackInsertFunctor(path)); + strings::Tokenize(name, "-", base::MakeBackInsertFunctor(path)); ForEachObject(c, path, geomType, rules); } @@ -170,7 +170,7 @@ pair<int, int> GetMinMax(int level, vector<uint32_t> const & types, drule::rule_ return res; } -string CombineArrT(my::StringIL const & arrT) +string CombineArrT(base::StringIL const & arrT) { string result; for (auto it = arrT.begin(); it != arrT.end(); ++it) @@ -182,7 +182,7 @@ string CombineArrT(my::StringIL const & arrT) return result; } -void CheckPriority(vector<my::StringIL> const & arrT, vector<size_t> const & arrI, drule::rule_type_t ruleType) +void CheckPriority(vector<base::StringIL> const & arrT, vector<size_t> const & arrI, drule::rule_type_t ruleType) { UnitTestInitPlatform(); Classificator const & c = classif(); @@ -240,7 +240,7 @@ void CheckPriority(vector<my::StringIL> const & arrT, vector<size_t> const & arr UNIT_TEST(Classificator_AreaPriority) { - vector<my::StringIL> types = + vector<base::StringIL> types = { // 0 {"natural", "coastline"}, @@ -261,7 +261,7 @@ UNIT_TEST(Classificator_AreaPriority) UNIT_TEST(Classificator_PoiPriority) { { - vector<my::StringIL> types = + vector<base::StringIL> types = { // 1 {"amenity", "atm"}, @@ -273,7 +273,7 @@ UNIT_TEST(Classificator_PoiPriority) } { - vector<my::StringIL> types = + vector<base::StringIL> types = { // 1 {"amenity", "bench"}, {"amenity", "shelter"}, diff --git a/map/user.cpp b/map/user.cpp index 2ecd56ac03..6465e044ba 100644 --- a/map/user.cpp +++ b/map/user.cpp @@ -408,7 +408,7 @@ void User::NotifySubscribersImpl() void User::ClearSubscribersImpl() { - my::EraseIf(m_subscribers, [](auto const & s) { return s == nullptr; }); + base::EraseIf(m_subscribers, [](auto const & s) { return s == nullptr; }); } void User::RequestUserDetails() diff --git a/map/user_mark_layer.cpp b/map/user_mark_layer.cpp index 0a8255cda2..9e1256489f 100644 --- a/map/user_mark_layer.cpp +++ b/map/user_mark_layer.cpp @@ -6,7 +6,7 @@ #include "base/macros.hpp" #include "base/scope_guard.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <utility> diff --git a/openlr/candidate_paths_getter.cpp b/openlr/candidate_paths_getter.cpp index 85aa916826..2f4ead930b 100644 --- a/openlr/candidate_paths_getter.cpp +++ b/openlr/candidate_paths_getter.cpp @@ -178,7 +178,7 @@ void CandidatePathsGetter::GetStartLines(vector<m2::PointD> const & points, bool } // Same edges may start on different points if those points are close enough. - my::SortUnique(edges, less<Graph::Edge>(), EdgesAreAlmostEqual); + base::SortUnique(edges, less<Graph::Edge>(), EdgesAreAlmostEqual); } void CandidatePathsGetter::GetAllSuitablePaths(Graph::EdgeVector const & startLines, diff --git a/openlr/candidate_points_getter.cpp b/openlr/candidate_points_getter.cpp index 6c110ae336..7985c3c7f8 100644 --- a/openlr/candidate_points_getter.cpp +++ b/openlr/candidate_points_getter.cpp @@ -38,12 +38,12 @@ void CandidatePointsGetter::GetJunctionPointCandidates(m2::PointD const & p, // later. The idea to fix this was to move SortUnique to the stage // after enriching with projections. - my::SortUnique(candidates, - [&p](m2::PointD const & a, m2::PointD const & b) { - return MercatorBounds::DistanceOnEarth(a, p) < - MercatorBounds::DistanceOnEarth(b, p); - }, - [](m2::PointD const & a, m2::PointD const & b) { return a == b; }); + base::SortUnique(candidates, + [&p](m2::PointD const & a, m2::PointD const & b) { + return MercatorBounds::DistanceOnEarth(a, p) < + MercatorBounds::DistanceOnEarth(b, p); + }, + [](m2::PointD const & a, m2::PointD const & b) { return a == b; }); candidates.resize(min(m_maxJunctionCandidates, candidates.size())); } diff --git a/openlr/openlr_stat/openlr_stat.cpp b/openlr/openlr_stat/openlr_stat.cpp index 74791d3ab7..4a94bd63db 100644 --- a/openlr/openlr_stat/openlr_stat.cpp +++ b/openlr/openlr_stat/openlr_stat.cpp @@ -194,10 +194,10 @@ std::vector<LinearSegment> LoadSegments(pugi::xml_document & document) segments.resize(FLAGS_limit); } - my::EraseIf(segments, - [&filter](LinearSegment const & segment) { return !filter.Matches(segment); }); + base::EraseIf(segments, + [&filter](LinearSegment const & segment) { return !filter.Matches(segment); }); - std::sort(segments.begin(), segments.end(), my::LessBy(&LinearSegment::m_segmentId)); + std::sort(segments.begin(), segments.end(), base::LessBy(&LinearSegment::m_segmentId)); return segments; } diff --git a/openlr/router.cpp b/openlr/router.cpp index 6f0b4bb2d8..b3e4095d58 100644 --- a/openlr/router.cpp +++ b/openlr/router.cpp @@ -666,7 +666,7 @@ bool Router::ReconstructPath(std::vector<Edge> & edges, vector<routing::Edge> & double const kFakeCoverageThreshold = 0.5; - my::EraseIf(edges, std::mem_fn(&Edge::IsSpecial)); + base::EraseIf(edges, std::mem_fn(&Edge::IsSpecial)); { size_t const n = FindPrefixLengthToConsume( diff --git a/platform/measurement_utils.cpp b/platform/measurement_utils.cpp index fe5a7d02b7..9e5934fec1 100644 --- a/platform/measurement_utils.cpp +++ b/platform/measurement_utils.cpp @@ -6,7 +6,7 @@ #include "base/assert.hpp" #include "base/macros.hpp" #include "base/math.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cmath> diff --git a/platform/string_storage_base.cpp b/platform/string_storage_base.cpp index e6075f5104..2850435346 100644 --- a/platform/string_storage_base.cpp +++ b/platform/string_storage_base.cpp @@ -4,9 +4,9 @@ #include "coding/file_reader.hpp" #include "coding/file_writer.hpp" -#include "base/logging.hpp" #include "base/exception.hpp" -#include "base/stl_add.hpp" +#include "base/logging.hpp" +#include "base/stl_helpers.hpp" #include <istream> diff --git a/precompiled_headers.hpp b/precompiled_headers.hpp index 607063ac36..affdf94893 100644 --- a/precompiled_headers.hpp +++ b/precompiled_headers.hpp @@ -9,7 +9,7 @@ #include "base/assert.hpp" #include "base/logging.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <algorithm> diff --git a/qt/editor_dialog.cpp b/qt/editor_dialog.cpp index 7545f8bbf1..b4c5e448cd 100644 --- a/qt/editor_dialog.cpp +++ b/qt/editor_dialog.cpp @@ -2,8 +2,8 @@ #include "indexer/editable_map_object.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" -#include "base/stl_add.hpp" #include "std/algorithm.hpp" @@ -247,7 +247,7 @@ void EditorDialog::OnSave() case osm::Props::Cuisine: { vector<string> cuisines; - strings::Tokenize(v, ";", MakeBackInsertFunctor(cuisines)); + strings::Tokenize(v, ";", base::MakeBackInsertFunctor(cuisines)); m_feature.SetCuisines(cuisines); } break; diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index a08d742dda..d8b6e1b4f4 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -290,7 +290,7 @@ void BicycleDirectionsEngine::GetSegmentRangeAndAdjacentEdges( } if (outgoingTurns.isCandidatesAngleValid) - sort(outgoingTurns.candidates.begin(), outgoingTurns.candidates.end(), my::LessBy(&TurnCandidate::m_angle)); + sort(outgoingTurns.candidates.begin(), outgoingTurns.candidates.end(), base::LessBy(&TurnCandidate::m_angle)); } void BicycleDirectionsEngine::GetEdges(RoadGraphBase const & graph, Junction const & currJunction, diff --git a/routing/cross_mwm_graph.cpp b/routing/cross_mwm_graph.cpp index f2d42b0d18..4db5357235 100644 --- a/routing/cross_mwm_graph.cpp +++ b/routing/cross_mwm_graph.cpp @@ -215,7 +215,7 @@ void CrossMwmGraph::GetTwins(Segment const & s, bool isOutgoing, vector<Segment> } } - my::SortUnique(twins); + base::SortUnique(twins); } for (Segment const & t : twins) diff --git a/routing/fake_graph.hpp b/routing/fake_graph.hpp index d3ba504a26..5db2a2e356 100644 --- a/routing/fake_graph.hpp +++ b/routing/fake_graph.hpp @@ -59,7 +59,7 @@ public: std::map<SegmentType, VertexType> const & rhs) { auto const counter = std::set_intersection(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), CounterIterator(), - my::LessBy(&std::pair<SegmentType, VertexType>::first)); + base::LessBy(&std::pair<SegmentType, VertexType>::first)); return counter.GetCount() == 0; }; diff --git a/routing/index_router.cpp b/routing/index_router.cpp index c9b0a09933..432a02e674 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -701,9 +701,10 @@ bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & d }; // Getting rid of knowingly bad candidates. - my::EraseIf(candidates, [&](pair<Edge, Junction> const & p) { + base::EraseIf(candidates, [&](pair<Edge, Junction> const & p) { Edge const & edge = p.first; - return edge.GetFeatureId().m_mwmId != mwmId || IsDeadEnd(getSegmentByEdge(edge), isOutgoing, worldGraph); + return edge.GetFeatureId().m_mwmId != mwmId || + IsDeadEnd(getSegmentByEdge(edge), isOutgoing, worldGraph); }); if (candidates.empty()) diff --git a/routing/online_absent_fetcher.cpp b/routing/online_absent_fetcher.cpp index 1053d41d9f..1b5d97e79a 100644 --- a/routing/online_absent_fetcher.cpp +++ b/routing/online_absent_fetcher.cpp @@ -60,7 +60,7 @@ void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries } m_fetcherThread.reset(); - my::SortUnique(countries); + base::SortUnique(countries); } bool OnlineAbsentCountriesFetcher::AllPointsInSameMwm(Checkpoints const & checkpoints) const diff --git a/routing/restriction_loader.cpp b/routing/restriction_loader.cpp index d7b1f48db2..421bc7071a 100644 --- a/routing/restriction_loader.cpp +++ b/routing/restriction_loader.cpp @@ -91,6 +91,6 @@ void ConvertRestrictionsOnlyToNoAndSort(IndexGraph const & graph, } }); } - my::SortUnique(restrictionsNo); + base::SortUnique(restrictionsNo); } } // namespace routing diff --git a/routing/routing_helpers.cpp b/routing/routing_helpers.cpp index ee3bcc5776..7a31eec665 100644 --- a/routing/routing_helpers.cpp +++ b/routing/routing_helpers.cpp @@ -23,9 +23,9 @@ void FillSegmentInfo(vector<Segment> const & segments, vector<Junction> const & CHECK(!turns.empty(), ()); CHECK(!times.empty(), ()); - CHECK(is_sorted(turns.cbegin(), turns.cend(), my::LessBy(&turns::TurnItem::m_index)), ()); - CHECK(is_sorted(streets.cbegin(), streets.cend(), my::LessBy(&Route::TStreetItem::first)), ()); - CHECK(is_sorted(times.cbegin(), times.cend(), my::LessBy(&Route::TTimeItem::first)), ()); + CHECK(is_sorted(turns.cbegin(), turns.cend(), base::LessBy(&turns::TurnItem::m_index)), ()); + CHECK(is_sorted(streets.cbegin(), streets.cend(), base::LessBy(&Route::TStreetItem::first)), ()); + CHECK(is_sorted(times.cbegin(), times.cend(), base::LessBy(&Route::TTimeItem::first)), ()); CHECK_LESS(turns.back().m_index, junctions.size(), ()); if (!streets.empty()) diff --git a/routing/turns.cpp b/routing/turns.cpp index 41174f4f85..e945ccf2c5 100644 --- a/routing/turns.cpp +++ b/routing/turns.cpp @@ -315,7 +315,7 @@ bool ParseLanes(string lanesString, vector<SingleLaneInfo> & lanes) return false; lanes.clear(); strings::AsciiToLower(lanesString); - my::EraseIf(lanesString, [](char c) { return isspace(c); }); + base::EraseIf(lanesString, [](char c) { return isspace(c); }); vector<string> SplitLanesStrings; SingleLaneInfo lane; diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index da90a6f11d..1f6e1277c4 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -853,7 +853,7 @@ void GetTurnDirection(IRoutingResult const & result, size_t outgoingSegmentIndex if (nodes.isCandidatesAngleValid) { ASSERT(is_sorted(nodes.candidates.begin(), nodes.candidates - .end(), my::LessBy(&TurnCandidate::m_angle)), + .end(), base::LessBy(&TurnCandidate::m_angle)), ("Turn candidates should be sorted by its angle field.")); } diff --git a/search/base/mem_search_index.hpp b/search/base/mem_search_index.hpp index a92e05b162..f152474505 100644 --- a/search/base/mem_search_index.hpp +++ b/search/base/mem_search_index.hpp @@ -6,7 +6,6 @@ #include "base/assert.hpp" #include "base/mem_trie.hpp" -#include "base/stl_add.hpp" #include "base/stl_helpers.hpp" #include "base/string_utils.hpp" @@ -92,7 +91,7 @@ private: { std::vector<Id> ids; fn(ids); - my::SortUnique(ids); + ::base::SortUnique(ids); return ids; } diff --git a/search/base/text_index/mem.cpp b/search/base/text_index/mem.cpp index 4c18f3b90f..f192f91a31 100644 --- a/search/base/text_index/mem.cpp +++ b/search/base/text_index/mem.cpp @@ -21,7 +21,7 @@ void MemTextIndex::SortPostings() // so we remove duplicates for the docid index. // If the count is needed for ranking it may be stored // separately. - my::SortUnique(entry.second); + ::base::SortUnique(entry.second); } } diff --git a/search/base/text_index/merger.cpp b/search/base/text_index/merger.cpp index 50f8af1d9a..931c583660 100644 --- a/search/base/text_index/merger.cpp +++ b/search/base/text_index/merger.cpp @@ -10,7 +10,6 @@ #include "base/assert.hpp" #include "base/logging.hpp" -#include "base/stl_add.hpp" #include "base/stl_helpers.hpp" #include <algorithm> @@ -70,9 +69,9 @@ private: return; auto const & tokens = m_dict.GetTokens(); - m_index1.ForEachPosting(tokens[m_tokenId], MakeBackInsertFunctor(m_postings)); - m_index2.ForEachPosting(tokens[m_tokenId], MakeBackInsertFunctor(m_postings)); - my::SortUnique(m_postings); + m_index1.ForEachPosting(tokens[m_tokenId], ::base::MakeBackInsertFunctor(m_postings)); + m_index2.ForEachPosting(tokens[m_tokenId], ::base::MakeBackInsertFunctor(m_postings)); + ::base::SortUnique(m_postings); } TextIndexDictionary const & m_dict; diff --git a/search/bookmarks/processor.cpp b/search/bookmarks/processor.cpp index d44b2fa66f..4083016247 100644 --- a/search/bookmarks/processor.cpp +++ b/search/bookmarks/processor.cpp @@ -103,7 +103,7 @@ void Processor::Erase(Id const & id) void Processor::Search(QueryParams const & params) const { set<Id> ids; - auto insertId = MakeInsertFunctor(ids); + auto insertId = ::base::MakeInsertFunctor(ids); for (size_t i = 0; i < params.GetNumTokens(); ++i) { diff --git a/search/engine.cpp b/search/engine.cpp index 7fac0f5da5..1ae71962f0 100644 --- a/search/engine.cpp +++ b/search/engine.cpp @@ -18,7 +18,7 @@ #include "base/logging.hpp" #include "base/scope_guard.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <cstdint> diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp index 862db56327..3bfc9653f6 100644 --- a/search/feature_offset_match.hpp +++ b/search/feature_offset_match.hpp @@ -11,7 +11,7 @@ #include "base/assert.hpp" #include "base/dfa_helpers.hpp" #include "base/levenshtein_dfa.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "base/uni_string_dfa.hpp" diff --git a/search/features_layer_path_finder.cpp b/search/features_layer_path_finder.cpp index f19af9058d..35bf95fae8 100644 --- a/search/features_layer_path_finder.cpp +++ b/search/features_layer_path_finder.cpp @@ -138,7 +138,7 @@ void FeaturesLayerPathFinder::FindReachableVerticesTopDown( parentGraph.emplace_back(); FeaturesLayer parent(*layers[i]); if (i != layers.size() - 1) - my::SortUnique(reachable); + ::base::SortUnique(reachable); parent.m_sortedFeatures = &reachable; // The first condition is an optimization: it is enough to extract @@ -202,7 +202,7 @@ void FeaturesLayerPathFinder::FindReachableVerticesBottomUp( parentGraph.emplace_front(); FeaturesLayer child(*layers[i]); if (i != 0) - my::SortUnique(reachable); + ::base::SortUnique(reachable); child.m_sortedFeatures = &reachable; child.m_hasDelayedFeatures = (i == 0 && MayHaveDelayedFeatures(child)); @@ -216,7 +216,7 @@ void FeaturesLayerPathFinder::FindReachableVerticesBottomUp( first = false; } - my::SortUnique(lowestLevel); + ::base::SortUnique(lowestLevel); IntersectionResult result; for (auto const & id : lowestLevel) diff --git a/search/geocoder.cpp b/search/geocoder.cpp index ec3fd5f77b..a49cb927c6 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -428,7 +428,7 @@ void Geocoder::GoInViewport() vector<shared_ptr<MwmInfo>> infos; m_dataSource.GetMwmsInfo(infos); - my::EraseIf(infos, [this](shared_ptr<MwmInfo> const & info) { + ::base::EraseIf(infos, [this](shared_ptr<MwmInfo> const & info) { return !m_params.m_pivot.IsIntersect(info->m_bordersRect); }); @@ -1169,7 +1169,7 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken) return !filtered.HasBit(bit); }; for (auto & cluster : clusters) - my::EraseIf(cluster, noFeature); + ::base::EraseIf(cluster, noFeature); size_t curs[kNumClusters] = {}; size_t ends[kNumClusters]; @@ -1275,7 +1275,7 @@ void Geocoder::FindPaths(BaseContext & ctx) sortedLayers.reserve(layers.size()); for (auto const & layer : layers) sortedLayers.push_back(&layer); - sort(sortedLayers.begin(), sortedLayers.end(), my::LessBy(&FeaturesLayer::m_type)); + sort(sortedLayers.begin(), sortedLayers.end(), ::base::LessBy(&FeaturesLayer::m_type)); auto const & innermostLayer = *sortedLayers.front(); diff --git a/search/geocoder_context.cpp b/search/geocoder_context.cpp index 21e42e235e..efca03df32 100644 --- a/search/geocoder_context.cpp +++ b/search/geocoder_context.cpp @@ -3,7 +3,7 @@ #include "search/token_range.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" using namespace std; diff --git a/search/house_detector.cpp b/search/house_detector.cpp index 7c46461971..d98be7eec2 100644 --- a/search/house_detector.cpp +++ b/search/house_detector.cpp @@ -851,7 +851,7 @@ int HouseDetector::LoadStreets(vector<FeatureID> const & ids) { // LOG(LDEBUG, ("IDs = ", ids)); - ASSERT(IsSortedAndUnique(ids.begin(), ids.end()), ()); + ASSERT(base::IsSortedAndUnique(ids.begin(), ids.end()), ()); // Check if the cache is obsolete and need to be cleared. if (!m_id2st.empty()) @@ -1191,7 +1191,7 @@ void HouseDetector::ClearUnusedStreets(vector<FeatureID> const & ids) m_streets.erase(remove_if(m_streets.begin(), m_streets.end(), HasStreet(streets)), m_streets.end()); - for_each(streets.begin(), streets.end(), DeleteFunctor()); + for_each(streets.begin(), streets.end(), base::DeleteFunctor()); } template <typename T> diff --git a/search/keyword_lang_matcher.cpp b/search/keyword_lang_matcher.cpp index 993e737403..840dac7e40 100644 --- a/search/keyword_lang_matcher.cpp +++ b/search/keyword_lang_matcher.cpp @@ -4,7 +4,7 @@ #include "indexer/search_string_utils.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <limits> diff --git a/search/keyword_matcher.cpp b/search/keyword_matcher.cpp index 4ebdb53ea6..e0efafb243 100644 --- a/search/keyword_matcher.cpp +++ b/search/keyword_matcher.cpp @@ -5,7 +5,7 @@ #include "base/assert.hpp" #include "base/buffer_vector.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <algorithm> #include <sstream> @@ -40,7 +40,7 @@ KeywordMatcher::Score KeywordMatcher::CalcScore(string const & name) const KeywordMatcher::Score KeywordMatcher::CalcScore(strings::UniString const & name) const { buffer_vector<strings::UniString, kMaxNumTokens> tokens; - SplitUniString(name, MakeBackInsertFunctor(tokens), Delimiters()); + SplitUniString(name, ::base::MakeBackInsertFunctor(tokens), Delimiters()); return CalcScore(tokens.data(), tokens.size()); } diff --git a/search/locality_scorer.cpp b/search/locality_scorer.cpp index cb4c45d262..5f042be0c2 100644 --- a/search/locality_scorer.cpp +++ b/search/locality_scorer.cpp @@ -178,7 +178,7 @@ void LocalityScorer::LeaveTopByNormAndRank(size_t limitUniqueIds, vector<ExLocal seen.insert(els[i].GetId()); ASSERT_LESS_OR_EQUAL(seen.size(), limitUniqueIds, ()); - my::EraseIf(els, [&](ExLocality const & el) { return seen.find(el.GetId()) == seen.cend(); }); + ::base::EraseIf(els, [&](ExLocality const & el) { return seen.find(el.GetId()) == seen.cend(); }); } void LocalityScorer::LeaveTopBySimilarityAndRank(size_t limit, vector<ExLocality> & els) const diff --git a/search/model.cpp b/search/model.cpp index c532549af5..6387b001d2 100644 --- a/search/model.cpp +++ b/search/model.cpp @@ -4,7 +4,7 @@ #include "indexer/feature.hpp" #include "base/macros.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" using namespace ftypes; @@ -13,14 +13,14 @@ namespace search TwoLevelPOIChecker::TwoLevelPOIChecker() : ftypes::BaseChecker(2 /* level */) { Classificator const & c = classif(); - my::StringIL arr[] = {{"highway", "bus_stop"}, - {"highway", "speed_camera"}, - {"waterway", "waterfall"}, - {"natural", "volcano"}, - {"natural", "cave_entrance"}, - {"natural", "beach"}, - {"emergency", "defibrillator"}, - {"emergency", "fire_hydrant"}}; + base::StringIL arr[] = {{"highway", "bus_stop"}, + {"highway", "speed_camera"}, + {"waterway", "waterfall"}, + {"natural", "volcano"}, + {"natural", "cave_entrance"}, + {"natural", "beach"}, + {"emergency", "defibrillator"}, + {"emergency", "fire_hydrant"}}; for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) m_types.push_back(c.GetTypeByPath(arr[i])); diff --git a/search/nested_rects_cache.cpp b/search/nested_rects_cache.cpp index 6e5b87fe5a..bb8e64edc0 100644 --- a/search/nested_rects_cache.cpp +++ b/search/nested_rects_cache.cpp @@ -8,7 +8,7 @@ #include "geometry/rect2d.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/algorithm.hpp" diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp index f914574f7b..adc51d6ac4 100644 --- a/search/pre_ranker.cpp +++ b/search/pre_ranker.cpp @@ -141,7 +141,7 @@ void PreRanker::Filter(bool viewportSearch) }; sort(m_results.begin(), m_results.end(), comparePreRankerResults); - m_results.erase(unique(m_results.begin(), m_results.end(), my::EqualsBy(&PreRankerResult::GetId)), + m_results.erase(unique(m_results.begin(), m_results.end(), base::EqualsBy(&PreRankerResult::GetId)), m_results.end()); bool const centersLoaded = @@ -243,7 +243,7 @@ void PreRanker::FilterForViewportSearch() { auto const & viewport = m_params.m_viewport; - my::EraseIf(m_results, [&viewport](PreRankerResult const & result) { + ::base::EraseIf(m_results, [&viewport](PreRankerResult const & result) { auto const & info = result.GetInfo(); return !viewport.IsPointInside(info.m_center); }); diff --git a/search/processor.cpp b/search/processor.cpp index 1c7acf2dbb..0a75ea6b89 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -44,7 +44,6 @@ #include "base/logging.hpp" #include "base/macros.hpp" #include "base/scope_guard.hpp" -#include "base/stl_add.hpp" #include "base/stl_helpers.hpp" #include "base/string_utils.hpp" @@ -223,7 +222,7 @@ void Processor::SetQuery(string const & query) vector<strings::UniString> tokens; { search::DelimitersWithExceptions delims(vector<strings::UniChar>{'#'}); - SplitUniString(NormalizeAndSimplifyString(query), MakeBackInsertFunctor(tokens), delims); + SplitUniString(NormalizeAndSimplifyString(query), ::base::MakeBackInsertFunctor(tokens), delims); } search::Delimiters delims; @@ -238,7 +237,7 @@ void Processor::SetQuery(string const & query) // Splits |token| by hashtags, because all other delimiters are // already removed. subTokens.clear(); - SplitUniString(token, MakeBackInsertFunctor(subTokens), delims); + SplitUniString(token, ::base::MakeBackInsertFunctor(subTokens), delims); if (subTokens.empty()) continue; @@ -281,7 +280,7 @@ void Processor::SetQuery(string const & query) if (!m_isCategorialRequest) ForEachCategoryType(tokenSlice, [&](size_t, uint32_t t) { m_preferredTypes.push_back(t); }); - my::SortUnique(m_preferredTypes); + ::base::SortUnique(m_preferredTypes); } m2::PointD Processor::GetPivotPoint(bool viewportSearch) const @@ -531,7 +530,7 @@ void Processor::InitParams(QueryParams & params) const } for (size_t i = 0; i < params.GetNumTokens(); ++i) - my::SortUnique(params.GetTypeIndices(i)); + ::base::SortUnique(params.GetTypeIndices(i)); m_keywordsScorer.ForEachLanguage( [&](int8_t lang) { params.GetLangs().Insert(static_cast<uint64_t>(lang)); }); diff --git a/search/ranker.cpp b/search/ranker.cpp index 55c2e4a8ec..150538137f 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -478,7 +478,7 @@ void Ranker::UpdateResults(bool lastUpdate) if (m_params.m_viewportSearch) { sort(m_tentativeResults.begin(), m_tentativeResults.end(), - my::LessBy(&RankerResult::GetDistanceToPivot)); + ::base::LessBy(&RankerResult::GetDistanceToPivot)); } else { @@ -486,7 +486,7 @@ void Ranker::UpdateResults(bool lastUpdate) // but the model is lightweight enough and the slowdown // is negligible. sort(m_tentativeResults.rbegin(), m_tentativeResults.rend(), - my::LessBy(&RankerResult::GetLinearModelRank)); + ::base::LessBy(&RankerResult::GetLinearModelRank)); ProcessSuggestions(m_tentativeResults); } diff --git a/search/ranking_utils.hpp b/search/ranking_utils.hpp index b81aeae15a..c4077e7d01 100644 --- a/search/ranking_utils.hpp +++ b/search/ranking_utils.hpp @@ -8,7 +8,7 @@ #include "indexer/search_string_utils.hpp" #include "base/levenshtein_dfa.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <algorithm> @@ -133,7 +133,7 @@ NameScore GetNameScore(std::string const & name, Slice const & slice) return NAME_SCORE_ZERO; std::vector<strings::UniString> tokens; - SplitUniString(NormalizeAndSimplifyString(name), MakeBackInsertFunctor(tokens), Delimiters()); + SplitUniString(NormalizeAndSimplifyString(name), ::base::MakeBackInsertFunctor(tokens), Delimiters()); return GetNameScore(tokens, slice); } diff --git a/search/region_info_getter.cpp b/search/region_info_getter.cpp index 37a7e980d5..7626f98a0c 100644 --- a/search/region_info_getter.cpp +++ b/search/region_info_getter.cpp @@ -64,7 +64,7 @@ string RegionInfoGetter::GetLocalizedFullName(storage::TCountryId const & id) co if (parts.size() > kMaxNumParts) parts.erase(parts.begin(), parts.end() - kMaxNumParts); - my::EraseIf(parts, [&](string const & s) { return s.empty(); }); + ::base::EraseIf(parts, [&](string const & s) { return s.empty(); }); if (!parts.empty()) return strings::JoinStrings(parts, ", "); diff --git a/search/retrieval.cpp b/search/retrieval.cpp index fd56851ff3..2e4a1a6b25 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -107,7 +107,7 @@ private: unique_ptr<coding::CompressedBitVector> SortFeaturesAndBuildCBV(vector<uint64_t> && features) { - my::SortUnique(features); + ::base::SortUnique(features); return coding::CompressedBitVectorBuilder::FromBitPositions(move(features)); } diff --git a/search/reverse_geocoder.cpp b/search/reverse_geocoder.cpp index b82b367b01..1d79158684 100644 --- a/search/reverse_geocoder.cpp +++ b/search/reverse_geocoder.cpp @@ -64,7 +64,7 @@ void GetNearbyStreetsImpl(DataSource const & source, MwmSet::MwmId const & id, fillStreets(move(mwmHandle), rect, addStreet); - sort(streets.begin(), streets.end(), my::LessBy(&ReverseGeocoder::Street::m_distanceMeters)); + sort(streets.begin(), streets.end(), ::base::LessBy(&ReverseGeocoder::Street::m_distanceMeters)); } } // namespace @@ -79,7 +79,7 @@ void ReverseGeocoder::GetNearbyStreets(search::MwmContext & context, m2::PointD auto const addStreet = [¢er, &streets](FeatureType & ft) { AddStreet(ft, center, streets); }; context.ForEachFeature(rect, addStreet); - sort(streets.begin(), streets.end(), my::LessBy(&Street::m_distanceMeters)); + sort(streets.begin(), streets.end(), ::base::LessBy(&Street::m_distanceMeters)); } void ReverseGeocoder::GetNearbyStreets(MwmSet::MwmId const & id, m2::PointD const & center, @@ -240,7 +240,7 @@ void ReverseGeocoder::GetNearbyBuildings(m2::PointD const & center, vector<Build }; m_dataSource.ForEachInRect(addBuilding, rect, kQueryScale); - sort(buildings.begin(), buildings.end(), my::LessBy(&Building::m_distanceMeters)); + sort(buildings.begin(), buildings.end(), ::base::LessBy(&Building::m_distanceMeters)); } // static diff --git a/search/search_integration_tests/generate_tests.cpp b/search/search_integration_tests/generate_tests.cpp index c90aa143e3..485a064457 100644 --- a/search/search_integration_tests/generate_tests.cpp +++ b/search/search_integration_tests/generate_tests.cpp @@ -14,7 +14,7 @@ #include "platform/local_country_file.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <cstdint> #include <set> @@ -69,7 +69,7 @@ UNIT_CLASS_TEST(GenerateTest, GenerateDeprecatedTypes) TEST_EQUAL(dataSource.Register(file).second, MwmSet::RegResult::Success, ()); // New types. - my::StringIL arr[] = {{"shop"}, {"office"}}; + base::StringIL arr[] = {{"shop"}, {"office"}}; Classificator const & cl = classif(); set<uint32_t> types; diff --git a/search/search_integration_tests/pre_ranker_test.cpp b/search/search_integration_tests/pre_ranker_test.cpp index 8a17f866ee..4e1479f76b 100644 --- a/search/search_integration_tests/pre_ranker_test.cpp +++ b/search/search_integration_tests/pre_ranker_test.cpp @@ -29,7 +29,7 @@ #include "base/cancellable.hpp" #include "base/limited_priority_queue.hpp" #include "base/math.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/algorithm.hpp" #include "std/iterator.hpp" @@ -153,7 +153,7 @@ UNIT_CLASS_TEST(PreRankerTest, Smoke) preRanker.UpdateResults(true /* lastUpdate */); - TEST(all_of(emit.begin(), emit.end(), IdFunctor()), (emit)); + TEST(all_of(emit.begin(), emit.end(), ::base::IdFunctor()), (emit)); TEST(ranker.Finished(), ()); TEST_EQUAL(results.size(), kBatchSize, ()); diff --git a/search/search_quality/matcher.cpp b/search/search_quality/matcher.cpp index 467ba078fa..3a4221232f 100644 --- a/search/search_quality/matcher.cpp +++ b/search/search_quality/matcher.cpp @@ -11,7 +11,7 @@ #include "geometry/mercator.hpp" #include "base/control_flow.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" namespace search { diff --git a/search/search_quality/search_quality_tool/search_quality_tool.cpp b/search/search_quality/search_quality_tool/search_quality_tool.cpp index 3f43841275..4b08a69260 100644 --- a/search/search_quality/search_quality_tool/search_quality_tool.cpp +++ b/search/search_quality/search_quality_tool/search_quality_tool.cpp @@ -28,7 +28,7 @@ #include "base/logging.hpp" #include "base/scope_guard.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "base/timer.hpp" diff --git a/search/search_tests/house_detector_tests.cpp b/search/search_tests/house_detector_tests.cpp index 6391d87985..375921f675 100644 --- a/search/search_tests/house_detector_tests.cpp +++ b/search/search_tests/house_detector_tests.cpp @@ -406,7 +406,7 @@ UNIT_TEST(HS_MWMSearch) continue; vector<string> v; - strings::Tokenize(line, "|", MakeBackInsertFunctor(v)); + strings::Tokenize(line, "|", ::base::MakeBackInsertFunctor(v)); string key = GetStreetKey(v[0]); if (key.empty()) diff --git a/search/search_tests/keyword_matcher_test.cpp b/search/search_tests/keyword_matcher_test.cpp index 3112fec91b..0132f1f4ac 100644 --- a/search/search_tests/keyword_matcher_test.cpp +++ b/search/search_tests/keyword_matcher_test.cpp @@ -7,7 +7,7 @@ #include "indexer/search_string_utils.hpp" #include "base/buffer_vector.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "std/sstream.hpp" #include "std/vector.hpp" diff --git a/search/search_tests/locality_scorer_test.cpp b/search/search_tests/locality_scorer_test.cpp index aa655212d4..e942f2b631 100644 --- a/search/search_tests/locality_scorer_test.cpp +++ b/search/search_tests/locality_scorer_test.cpp @@ -11,7 +11,6 @@ #include "base/assert.hpp" #include "base/mem_trie.hpp" -#include "base/stl_add.hpp" #include "base/stl_helpers.hpp" #include "base/string_utils.hpp" @@ -39,7 +38,7 @@ public: vector<UniString> tokens; Delimiters delims; - SplitUniString(NormalizeAndSimplifyString(query), MakeBackInsertFunctor(tokens), delims); + SplitUniString(NormalizeAndSimplifyString(query), ::base::MakeBackInsertFunctor(tokens), delims); if (lastTokenIsPrefix) { @@ -56,7 +55,7 @@ public: { set<UniString> tokens; Delimiters delims; - SplitUniString(NormalizeAndSimplifyString(name), MakeInsertFunctor(tokens), delims); + SplitUniString(NormalizeAndSimplifyString(name), base::MakeInsertFunctor(tokens), delims); for (auto const & token : tokens) m_searchIndex.Add(token, featureId); @@ -91,7 +90,7 @@ public: } }); - my::SortUnique(ids); + ::base::SortUnique(ids); ctx.m_features.emplace_back(coding::CompressedBitVectorBuilder::FromBitPositions(ids)); } @@ -100,7 +99,7 @@ public: vector<Locality> localities; m_scorer.GetTopLocalities(MwmSet::MwmId(), ctx, filter, limit, localities); - sort(localities.begin(), localities.end(), my::LessBy(&Locality::m_featureId)); + sort(localities.begin(), localities.end(), ::base::LessBy(&Locality::m_featureId)); Ids ids; for (auto const & locality : localities) @@ -136,7 +135,7 @@ public: m_searchIndex.ForEachInNode(token, [&ids](uint32_t id) { ids.push_back(id); }); } - my::SortUnique(ids); + ::base::SortUnique(ids); return CBV{coding::CompressedBitVectorBuilder::FromBitPositions(move(ids))}; } diff --git a/search/search_tests/mem_search_index_tests.cpp b/search/search_tests/mem_search_index_tests.cpp index 1e0cd99139..94eb8ca6e9 100644 --- a/search/search_tests/mem_search_index_tests.cpp +++ b/search/search_tests/mem_search_index_tests.cpp @@ -7,7 +7,6 @@ #include "coding/multilang_utf8_string.hpp" -#include "base/stl_add.hpp" #include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "base/uni_string_dfa.hpp" @@ -59,7 +58,7 @@ public: vector<Id> StrictQuery(string const & query, string const & lang) const { auto prev = m_index.GetAllIds(); - TEST(IsSortedAndUnique(prev.cbegin(), prev.cend()), ()); + TEST(::base::IsSortedAndUnique(prev.cbegin(), prev.cend()), ()); vector<UniString> tokens; NormalizeAndTokenizeString(query, tokens); @@ -73,7 +72,7 @@ public: MatchFeaturesInTrie(request, m_index.GetRootIterator(), [](Id const & /* id */) { return true; } /* filter */, [&curr](Id const & id) { curr.push_back(id); } /* toDo */); - my::SortUnique(curr); + ::base::SortUnique(curr); vector<Id> intersection; set_intersection(prev.begin(), prev.end(), curr.begin(), curr.end(), diff --git a/search/search_tests/ranking_tests.cpp b/search/search_tests/ranking_tests.cpp index 2b10b73d51..a870b94ae7 100644 --- a/search/search_tests/ranking_tests.cpp +++ b/search/search_tests/ranking_tests.cpp @@ -8,7 +8,7 @@ #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "std/cstdint.hpp" @@ -25,7 +25,7 @@ NameScore GetScore(string const & name, string const & query, TokenRange const & QueryParams params; vector<UniString> tokens; - SplitUniString(NormalizeAndSimplifyString(query), MakeBackInsertFunctor(tokens), delims); + SplitUniString(NormalizeAndSimplifyString(query), ::base::MakeBackInsertFunctor(tokens), delims); if (!query.empty() && !delims(strings::LastUniChar(query))) { diff --git a/search/search_tests/string_match_test.cpp b/search/search_tests/string_match_test.cpp index 961e0fd9be..97b0ac2cd6 100644 --- a/search/search_tests/string_match_test.cpp +++ b/search/search_tests/string_match_test.cpp @@ -4,7 +4,7 @@ #include "indexer/search_delimiters.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include <cstdint> @@ -111,7 +111,7 @@ UNIT_TEST(StringSplit_Smoke) TEST_EQUAL(ToUtf8(s1), s, ()); char const * arr[] = { "1", "2" }; - SplitUniString(s1, MakeBackInsertFunctor(tokens), Delimiters()); + SplitUniString(s1, ::base::MakeBackInsertFunctor(tokens), Delimiters()); TestEqual(tokens, arr); } } diff --git a/search/search_tests/text_index_tests.cpp b/search/search_tests/text_index_tests.cpp index b161007f14..7119e89286 100644 --- a/search/search_tests/text_index_tests.cpp +++ b/search/search_tests/text_index_tests.cpp @@ -14,7 +14,7 @@ #include "coding/write_to_sink.hpp" #include "coding/writer.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include "base/string_utils.hpp" #include "std/transform_iterator.hpp" @@ -72,7 +72,7 @@ template <typename Index, typename Token> void TestForEach(Index const & index, Token const & token, vector<uint32_t> const & expected) { vector<uint32_t> actual; - index.ForEachPosting(token, MakeBackInsertFunctor(actual)); + index.ForEachPosting(token, ::base::MakeBackInsertFunctor(actual)); TEST_EQUAL(actual, expected, (token)); }; } // namespace diff --git a/search/street_vicinity_loader.cpp b/search/street_vicinity_loader.cpp index ed5b9812b4..a10c8f0549 100644 --- a/search/street_vicinity_loader.cpp +++ b/search/street_vicinity_loader.cpp @@ -8,7 +8,7 @@ #include "geometry/point2d.hpp" #include "base/math.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" namespace search { @@ -50,7 +50,7 @@ void StreetVicinityLoader::LoadStreet(uint32_t featureId, Street & street) return; vector<m2::PointD> points; - feature.ForEachPoint(MakeBackInsertFunctor(points), FeatureType::BEST_GEOMETRY); + feature.ForEachPoint(::base::MakeBackInsertFunctor(points), FeatureType::BEST_GEOMETRY); ASSERT(!points.empty(), ()); for (auto const & point : points) @@ -58,7 +58,7 @@ void StreetVicinityLoader::LoadStreet(uint32_t featureId, Street & street) covering::CoveringGetter coveringGetter(street.m_rect, covering::ViewportWithLowLevels); auto const & intervals = coveringGetter.Get<RectId::DEPTH_LEVELS>(m_scale); - m_context->ForEachIndex(intervals, m_scale, MakeBackInsertFunctor(street.m_features)); + m_context->ForEachIndex(intervals, m_scale, ::base::MakeBackInsertFunctor(street.m_features)); street.m_calculator = make_unique<ProjectionOnStreetCalculator>(points); } diff --git a/search/streets_matcher.cpp b/search/streets_matcher.cpp index f852b1c742..7b71990501 100644 --- a/search/streets_matcher.cpp +++ b/search/streets_matcher.cpp @@ -42,10 +42,10 @@ void StreetsMatcher::Go(BaseContext const & ctx, FeaturesFilter const & filter, sort(predictions.begin(), predictions.end(), &LessByHash); predictions.erase( - unique(predictions.begin(), predictions.end(), my::EqualsBy(&Prediction::m_hash)), + unique(predictions.begin(), predictions.end(), base::EqualsBy(&Prediction::m_hash)), predictions.end()); - sort(predictions.rbegin(), predictions.rend(), my::LessBy(&Prediction::m_prob)); + sort(predictions.rbegin(), predictions.rend(), ::base::LessBy(&Prediction::m_prob)); while (predictions.size() > kMaxNumOfImprobablePredictions && predictions.back().m_prob < kTailProbability) { diff --git a/search/suggest.cpp b/search/suggest.cpp index 5272337d66..f6c6888e15 100644 --- a/search/suggest.cpp +++ b/search/suggest.cpp @@ -5,7 +5,7 @@ #include "search/common.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <vector> @@ -19,7 +19,7 @@ void GetSuggestion(RankerResult const & res, string const & query, QueryTokens c // Splits result's name. search::Delimiters delims; vector<strings::UniString> tokens; - SplitUniString(NormalizeAndSimplifyString(res.GetName()), MakeBackInsertFunctor(tokens), delims); + SplitUniString(NormalizeAndSimplifyString(res.GetName()), ::base::MakeBackInsertFunctor(tokens), delims); // Finds tokens that are already present in the input query. vector<bool> tokensMatched(tokens.size()); diff --git a/search/tracer.cpp b/search/tracer.cpp index f767d89440..0f2c5b4fa4 100644 --- a/search/tracer.cpp +++ b/search/tracer.cpp @@ -63,7 +63,7 @@ string DebugPrint(Tracer::Parse const & parse) vector<Tracer::Parse> Tracer::GetUniqueParses() const { auto parses = m_parses; - my::SortUnique(parses); + ::base::SortUnique(parses); return parses; } } // namespace search diff --git a/search/utils.cpp b/search/utils.cpp index ff8d2d0587..3cabefa58d 100644 --- a/search/utils.cpp +++ b/search/utils.cpp @@ -60,13 +60,13 @@ vector<uint32_t> GetCategoryTypes(string const & name, string const & locale, locales.Insert(static_cast<uint64_t>(code)); vector<strings::UniString> tokens; - SplitUniString(search::NormalizeAndSimplifyString(name), MakeBackInsertFunctor(tokens), + SplitUniString(search::NormalizeAndSimplifyString(name), ::base::MakeBackInsertFunctor(tokens), search::Delimiters()); FillCategories(QuerySliceOnRawStrings<vector<strings::UniString>>(tokens, {} /* prefix */), locales, categories, types); - my::SortUnique(types); + ::base::SortUnique(types); return types; } diff --git a/search/utils.hpp b/search/utils.hpp index 0942ade6fc..c9c8739f13 100644 --- a/search/utils.hpp +++ b/search/utils.hpp @@ -100,7 +100,7 @@ bool FillCategories(QuerySliceOnRawStrings<T> const & slice, Locales const & loc std::vector<QueryParams::String> categoryTokens; SplitUniString(search::NormalizeAndSimplifyString(categorySynonym.m_name), - MakeBackInsertFunctor(categoryTokens), search::Delimiters()); + ::base::MakeBackInsertFunctor(categoryTokens), search::Delimiters()); if (slice.Size() != categoryTokens.size()) return; diff --git a/software_renderer/feature_styler.cpp b/software_renderer/feature_styler.cpp index afb624056a..f744dd07c0 100644 --- a/software_renderer/feature_styler.cpp +++ b/software_renderer/feature_styler.cpp @@ -12,8 +12,8 @@ #include "geometry/screenbase.hpp" -#include "base/stl_add.hpp" #include "base/logging.hpp" +#include "base/stl_helpers.hpp" #include "std/iterator_facade.hpp" diff --git a/storage/country.cpp b/storage/country.cpp index 220ffde46c..5d290a309c 100644 --- a/storage/country.cpp +++ b/storage/country.cpp @@ -49,7 +49,7 @@ public: ~StoreCountriesSingleMwms() { for (auto & entry : m_affiliations) - my::SortUnique(entry.second); + base::SortUnique(entry.second); } // StoreSingleMwmInterface overrides: diff --git a/storage/pinger.cpp b/storage/pinger.cpp index dae285c576..bb66cd6c80 100644 --- a/storage/pinger.cpp +++ b/storage/pinger.cpp @@ -68,7 +68,7 @@ void Pinger::Ping(vector<string> const & urls, Pinger::Pong const & pong) t.Shutdown(base::WorkerThread::Exit::ExecPending); } - my::EraseIf(readyUrls, [](auto const & url) { return url.empty(); }); + base::EraseIf(readyUrls, [](auto const & url) { return url.empty(); }); SendStatistics(readyUrls.size()); pong(move(readyUrls)); } diff --git a/storage/storage.cpp b/storage/storage.cpp index a71551b079..ac88316151 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1389,7 +1389,7 @@ void Storage::GetChildrenInGroups(TCountryId const & parent, TCountriesVec & dow TCountriesVec uniqueDisputed(disputedTerritoriesWithoutSiblings.begin(), disputedTerritoriesWithoutSiblings.end()); - my::SortUnique(uniqueDisputed); + base::SortUnique(uniqueDisputed); for (auto const & countryId : uniqueDisputed) { diff --git a/track_analyzing/track_matcher.cpp b/track_analyzing/track_matcher.cpp index e87d6fe899..751f900f3a 100644 --- a/track_analyzing/track_matcher.cpp +++ b/track_analyzing/track_matcher.cpp @@ -190,7 +190,7 @@ void TrackMatcher::Step::FillCandidates(Step const & previousStep, IndexGraph & } } - my::SortUnique(m_candidates); + base::SortUnique(m_candidates); m_candidates.erase(remove_if(m_candidates.begin(), m_candidates.end(), [&](Candidate const & candidate) { diff --git a/transit/transit_graph_data.cpp b/transit/transit_graph_data.cpp index ea474816be..deacdce4d9 100644 --- a/transit/transit_graph_data.cpp +++ b/transit/transit_graph_data.cpp @@ -214,7 +214,7 @@ void GraphData::DeserializeFromJson(my::Json const & root, OsmIdToFeatureIdsMap // Note. It's possible that two stops are connected with the same line several times // in the same direction. It happens in Oslo metro (T-banen): // https://en.wikipedia.org/wiki/Oslo_Metro#/media/File:Oslo_Metro_Map.svg branch 5. - my::SortUnique(m_edges, + base::SortUnique(m_edges, [](Edge const & e1, Edge const & e2) { if (e1 != e2) return e1 < e2; diff --git a/transit/transit_tests/transit_json_parsing_test.cpp b/transit/transit_tests/transit_json_parsing_test.cpp index 0d2f392e43..5f6046243a 100644 --- a/transit/transit_tests/transit_json_parsing_test.cpp +++ b/transit/transit_tests/transit_json_parsing_test.cpp @@ -6,7 +6,7 @@ #include "transit/transit_types.hpp" #include "base/assert.hpp" -#include "base/stl_add.hpp" +#include "base/stl_helpers.hpp" #include <memory> #include <string> diff --git a/ugc/storage.cpp b/ugc/storage.cpp index 19d96e65aa..d475b54620 100644 --- a/ugc/storage.cpp +++ b/ugc/storage.cpp @@ -359,7 +359,7 @@ void Storage::DefragmentationImpl(bool force) return; } - my::EraseIf(m_indexes, [](UpdateIndex const & i) -> bool { return i.m_deleted; }); + base::EraseIf(m_indexes, [](UpdateIndex const & i) -> bool { return i.m_deleted; }); CHECK(my::DeleteFileX(ugcFilePath), ()); CHECK(my::RenameFileX(tmpUGCFilePath, ugcFilePath), ()); diff --git a/xcode/base/base.xcodeproj/project.pbxproj b/xcode/base/base.xcodeproj/project.pbxproj index 70b3fc9cd2..9527c1b9e2 100644 --- a/xcode/base/base.xcodeproj/project.pbxproj +++ b/xcode/base/base.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 3917FA69211E010400937DF4 /* fifo_cache_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 564BB446206E8A4D00BDD211 /* fifo_cache_test.cpp */; }; 3917FA6A211E010400937DF4 /* control_flow_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39B89C391FD1898A001104AF /* control_flow_tests.cpp */; }; 3917FA6B211E010400937DF4 /* small_set_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 67E40EC71E4DC0D500A6D200 /* small_set_test.cpp */; }; + 395FEB3521492F350036395C /* stl_helpers_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395FEB3321492F320036395C /* stl_helpers_tests.cpp */; }; 39BC0FD01FD057FA00B6C276 /* control_flow.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39BC0FCF1FD057F900B6C276 /* control_flow.hpp */; }; 39FD271E1CC65AD000AFF551 /* testingmain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD27011CC65A2800AFF551 /* testingmain.cpp */; }; 39FD271F1CC65AD000AFF551 /* assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26C81CC65A0E00AFF551 /* assert_test.cpp */; }; @@ -51,8 +52,6 @@ 39FD272D1CC65AD000AFF551 /* regexp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26D71CC65A0E00AFF551 /* regexp_test.cpp */; }; 39FD272E1CC65AD000AFF551 /* rolling_hash_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26D81CC65A0E00AFF551 /* rolling_hash_test.cpp */; }; 39FD272F1CC65AD000AFF551 /* scope_guard_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26D91CC65A0E00AFF551 /* scope_guard_test.cpp */; }; - 39FD27301CC65AD000AFF551 /* stl_add_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26DA1CC65A0E00AFF551 /* stl_add_test.cpp */; }; - 39FD27311CC65AD000AFF551 /* stl_helpers_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26DB1CC65A0E00AFF551 /* stl_helpers_test.cpp */; }; 39FD27321CC65AD000AFF551 /* string_format_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26DC1CC65A0E00AFF551 /* string_format_test.cpp */; }; 39FD27331CC65AD000AFF551 /* string_utils_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26DD1CC65A0E00AFF551 /* string_utils_test.cpp */; }; 39FD27341CC65AD000AFF551 /* sunrise_sunset_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39FD26DE1CC65A0E00AFF551 /* sunrise_sunset_test.cpp */; }; @@ -120,7 +119,6 @@ 675341FA1A3F57E400A0A8C3 /* src_point.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675341B51A3F57E400A0A8C3 /* src_point.hpp */; }; 675341FB1A3F57E400A0A8C3 /* stats.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675341B61A3F57E400A0A8C3 /* stats.hpp */; }; 675341FC1A3F57E400A0A8C3 /* std_serialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675341B71A3F57E400A0A8C3 /* std_serialization.hpp */; }; - 675341FD1A3F57E400A0A8C3 /* stl_add.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675341B81A3F57E400A0A8C3 /* stl_add.hpp */; }; 675341FE1A3F57E400A0A8C3 /* stl_iterator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675341B91A3F57E400A0A8C3 /* stl_iterator.hpp */; }; 675341FF1A3F57E400A0A8C3 /* string_format.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675341BA1A3F57E400A0A8C3 /* string_format.cpp */; }; 675342001A3F57E400A0A8C3 /* string_format.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675341BB1A3F57E400A0A8C3 /* string_format.hpp */; }; @@ -167,6 +165,7 @@ 3917FA5B211E00BB00937DF4 /* pprof.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pprof.hpp; sourceTree = "<group>"; }; 3917FA5E211E00C300937DF4 /* suffix_array.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = suffix_array.hpp; sourceTree = "<group>"; }; 3917FA60211E00F100937DF4 /* geo_object_id_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = geo_object_id_tests.cpp; sourceTree = "<group>"; }; + 395FEB3321492F320036395C /* stl_helpers_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stl_helpers_tests.cpp; sourceTree = "<group>"; }; 39B89C391FD1898A001104AF /* control_flow_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = control_flow_tests.cpp; sourceTree = "<group>"; }; 39BC0FCF1FD057F900B6C276 /* control_flow.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = control_flow.hpp; sourceTree = "<group>"; }; 39BC707420F55B6700A6EC20 /* clustering_map_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clustering_map_tests.cpp; sourceTree = "<group>"; }; @@ -191,8 +190,6 @@ 39FD26D71CC65A0E00AFF551 /* regexp_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = regexp_test.cpp; sourceTree = "<group>"; }; 39FD26D81CC65A0E00AFF551 /* rolling_hash_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rolling_hash_test.cpp; sourceTree = "<group>"; }; 39FD26D91CC65A0E00AFF551 /* scope_guard_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scope_guard_test.cpp; sourceTree = "<group>"; }; - 39FD26DA1CC65A0E00AFF551 /* stl_add_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stl_add_test.cpp; sourceTree = "<group>"; }; - 39FD26DB1CC65A0E00AFF551 /* stl_helpers_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stl_helpers_test.cpp; sourceTree = "<group>"; }; 39FD26DC1CC65A0E00AFF551 /* string_format_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_format_test.cpp; sourceTree = "<group>"; }; 39FD26DD1CC65A0E00AFF551 /* string_utils_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_utils_test.cpp; sourceTree = "<group>"; }; 39FD26DE1CC65A0E00AFF551 /* sunrise_sunset_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sunrise_sunset_test.cpp; sourceTree = "<group>"; }; @@ -267,7 +264,6 @@ 675341B51A3F57E400A0A8C3 /* src_point.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = src_point.hpp; sourceTree = "<group>"; }; 675341B61A3F57E400A0A8C3 /* stats.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stats.hpp; sourceTree = "<group>"; }; 675341B71A3F57E400A0A8C3 /* std_serialization.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = std_serialization.hpp; sourceTree = "<group>"; }; - 675341B81A3F57E400A0A8C3 /* stl_add.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stl_add.hpp; sourceTree = "<group>"; }; 675341B91A3F57E400A0A8C3 /* stl_iterator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stl_iterator.hpp; sourceTree = "<group>"; }; 675341BA1A3F57E400A0A8C3 /* string_format.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_format.cpp; sourceTree = "<group>"; }; 675341BB1A3F57E400A0A8C3 /* string_format.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = string_format.hpp; sourceTree = "<group>"; }; @@ -318,6 +314,7 @@ 39FD26C71CC659D200AFF551 /* base_tests */ = { isa = PBXGroup; children = ( + 395FEB3321492F320036395C /* stl_helpers_tests.cpp */, 3917FA60211E00F100937DF4 /* geo_object_id_tests.cpp */, 39F995DF20F55B8A0034F977 /* move_to_front_tests.cpp */, 39F995E120F55B8A0034F977 /* suffix_array_tests.cpp */, @@ -349,8 +346,6 @@ 39FD26D71CC65A0E00AFF551 /* regexp_test.cpp */, 39FD26D81CC65A0E00AFF551 /* rolling_hash_test.cpp */, 39FD26D91CC65A0E00AFF551 /* scope_guard_test.cpp */, - 39FD26DA1CC65A0E00AFF551 /* stl_add_test.cpp */, - 39FD26DB1CC65A0E00AFF551 /* stl_helpers_test.cpp */, 39FD26DC1CC65A0E00AFF551 /* string_format_test.cpp */, 39FD26DD1CC65A0E00AFF551 /* string_utils_test.cpp */, 39FD26DE1CC65A0E00AFF551 /* sunrise_sunset_test.cpp */, @@ -450,7 +445,6 @@ 675341B51A3F57E400A0A8C3 /* src_point.hpp */, 675341B61A3F57E400A0A8C3 /* stats.hpp */, 675341B71A3F57E400A0A8C3 /* std_serialization.hpp */, - 675341B81A3F57E400A0A8C3 /* stl_add.hpp */, 672DD4BA1E0425600078E13C /* stl_helpers.hpp */, 675341B91A3F57E400A0A8C3 /* stl_iterator.hpp */, 675341BA1A3F57E400A0A8C3 /* string_format.cpp */, @@ -580,7 +574,6 @@ 672DD4C61E0425600078E13C /* range_iterator.hpp in Headers */, 3917FA58211E009700937DF4 /* geo_object_id.hpp in Headers */, F6F8E3C91EF846CE00F2DE8F /* worker_thread.hpp in Headers */, - 675341FD1A3F57E400A0A8C3 /* stl_add.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -686,6 +679,7 @@ 3917FA6A211E010400937DF4 /* control_flow_tests.cpp in Sources */, 39FD27321CC65AD000AFF551 /* string_format_test.cpp in Sources */, 39FD272A1CC65AD000AFF551 /* mem_trie_test.cpp in Sources */, + 395FEB3521492F350036395C /* stl_helpers_tests.cpp in Sources */, 3446C67C1DDCAA4600146687 /* levenshtein_dfa_test.cpp in Sources */, 3917FA69211E010400937DF4 /* fifo_cache_test.cpp in Sources */, 39FD27381CC65AD000AFF551 /* timegm_test.cpp in Sources */, @@ -694,14 +688,12 @@ 3917FA67211E010400937DF4 /* bwt_tests.cpp in Sources */, 3446C6821DDCAA7400146687 /* newtype_test.cpp in Sources */, 39FD27231CC65AD000AFF551 /* collection_cast_test.cpp in Sources */, - 39FD27301CC65AD000AFF551 /* stl_add_test.cpp in Sources */, 39FD272E1CC65AD000AFF551 /* rolling_hash_test.cpp in Sources */, 39FD27361CC65AD000AFF551 /* threaded_list_test.cpp in Sources */, 3917FA63211E010400937DF4 /* move_to_front_tests.cpp in Sources */, 39FD272B1CC65AD000AFF551 /* observer_list_test.cpp in Sources */, 39FD27371CC65AD000AFF551 /* threads_test.cpp in Sources */, 39FD27331CC65AD000AFF551 /* string_utils_test.cpp in Sources */, - 39FD27311CC65AD000AFF551 /* stl_helpers_test.cpp in Sources */, 3446C6831DDCAA7800146687 /* ref_counted_tests.cpp in Sources */, 39FD27211CC65AD000AFF551 /* buffer_vector_test.cpp in Sources */, 3917FA64211E010400937DF4 /* suffix_array_tests.cpp in Sources */,