From 2b74e7ae672ebd82d19cf225a6ba3c489f72208f Mon Sep 17 00:00:00 2001 From: Tessil Date: Mon, 26 Aug 2024 18:07:55 +0100 Subject: [PATCH] Add .clang-format file and apply --- .clang-format | 1 + include/tsl/htrie_hash.h | 5 ++--- include/tsl/htrie_map.h | 4 ++-- include/tsl/htrie_set.h | 4 ++-- tests/trie_map_tests.cpp | 40 ++++++++++++++++++++-------------------- 5 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f6cb8ad --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: Google diff --git a/include/tsl/htrie_hash.h b/include/tsl/htrie_hash.h index 2a0c114..91ffc64 100644 --- a/include/tsl/htrie_hash.h +++ b/include/tsl/htrie_hash.h @@ -1619,9 +1619,8 @@ class htrie_hash { } template - void for_each_prefix_of_impl(N& search_start_node, - const CharT* value, size_type value_size, - F&& visitor) const { + void for_each_prefix_of_impl(N& search_start_node, const CharT* value, + size_type value_size, F&& visitor) const { auto* current_node = &search_start_node; for (size_type ivalue = 0; ivalue < value_size; ivalue++) { diff --git a/include/tsl/htrie_map.h b/include/tsl/htrie_map.h index 2869b8d..51cf8b1 100644 --- a/include/tsl/htrie_map.h +++ b/include/tsl/htrie_map.h @@ -601,8 +601,8 @@ class htrie_map { * @copydoc for_each_prefix_of_ks(const CharT*, size_type, F&&) */ template - void for_each_prefix_of( - const std::basic_string_view& key, F&& visitor) const { + void for_each_prefix_of(const std::basic_string_view& key, + F&& visitor) const { return m_ht.for_each_prefix_of(key.data(), key.size(), std::forward(visitor)); } diff --git a/include/tsl/htrie_set.h b/include/tsl/htrie_set.h index 772fb9c..0ec30cd 100644 --- a/include/tsl/htrie_set.h +++ b/include/tsl/htrie_set.h @@ -523,8 +523,8 @@ class htrie_set { * @copydoc for_each_prefix_of_ks(const CharT*, size_type, F&&) */ template - void for_each_prefix_of( - const std::basic_string_view& key, F&& visitor) const { + void for_each_prefix_of(const std::basic_string_view& key, + F&& visitor) const { return m_ht.for_each_prefix_of(key.data(), key.size(), std::forward(visitor)); } diff --git a/tests/trie_map_tests.cpp b/tests/trie_map_tests.cpp index 5f5cd67..30c3218 100644 --- a/tests/trie_map_tests.cpp +++ b/tests/trie_map_tests.cpp @@ -372,31 +372,31 @@ BOOST_AUTO_TEST_CASE(test_for_each_prefix_of) { {"abcdf", 1}, {"abcdg", 1}, {"abcdh", 1}, {"babc", 1}}; std::vector> test_vectors = { - {"a", {"a"}}, - {"aa", {"a", "aa"}}, - {"aaa", {"a", "aa", "aaa"}}, - {"aaaa", {"a", "aa", "aaa"}}, - {"ab", {"a", "ab"}}, - {"abc", {"a", "ab"}}, - {"abcd", {"a", "ab"}}, - {"abcdz", {"a", "ab"}}, - {"abcde", {"a", "ab", "abcde"}}, - {"abcdef", {"a", "ab", "abcde"}}, - {"abcdefg", {"a", "ab", "abcde"}}, - {"dabc", {}}, - {"b", {}}, - {"bab", {}}, - {"babd", {}}, - {"", {}}, + {"a", {"a"}}, + {"aa", {"a", "aa"}}, + {"aaa", {"a", "aa", "aaa"}}, + {"aaaa", {"a", "aa", "aaa"}}, + {"ab", {"a", "ab"}}, + {"abc", {"a", "ab"}}, + {"abcd", {"a", "ab"}}, + {"abcdz", {"a", "ab"}}, + {"abcde", {"a", "ab", "abcde"}}, + {"abcdef", {"a", "ab", "abcde"}}, + {"abcdefg", {"a", "ab", "abcde"}}, + {"dabc", {}}, + {"b", {}}, + {"bab", {}}, + {"babd", {}}, + {"", {}}, }; - for (const auto& v: test_vectors) { + for (const auto& v : test_vectors) { path_type p; const path_type& expected = v.second; - auto visitor = [&p](map_type::const_iterator it) {p.push_back(it.key());}; + auto visitor = [&p](map_type::const_iterator it) { p.push_back(it.key()); }; map.for_each_prefix_of(v.first, visitor); - BOOST_CHECK_EQUAL_COLLECTIONS(p.begin(), p.end(), - expected.begin(), expected.end()); + BOOST_CHECK_EQUAL_COLLECTIONS(p.begin(), p.end(), expected.begin(), + expected.end()); if (p != expected) BOOST_TEST_MESSAGE("...for test vector input '" << v.first << "'"); }