Skip to content

Commit

Permalink
Add .clang-format file and apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Tessil committed Aug 26, 2024
1 parent 19b81d7 commit 2b74e7a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: Google
5 changes: 2 additions & 3 deletions include/tsl/htrie_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,8 @@ class htrie_hash {
}

template <class Iterator, class N, class F>
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++) {
Expand Down
4 changes: 2 additions & 2 deletions include/tsl/htrie_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ class htrie_map {
* @copydoc for_each_prefix_of_ks(const CharT*, size_type, F&&)
*/
template <typename F>
void for_each_prefix_of(
const std::basic_string_view<CharT>& key, F&& visitor) const {
void for_each_prefix_of(const std::basic_string_view<CharT>& key,
F&& visitor) const {
return m_ht.for_each_prefix_of(key.data(), key.size(),
std::forward<F>(visitor));
}
Expand Down
4 changes: 2 additions & 2 deletions include/tsl/htrie_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ class htrie_set {
* @copydoc for_each_prefix_of_ks(const CharT*, size_type, F&&)
*/
template <typename F>
void for_each_prefix_of(
const std::basic_string_view<CharT>& key, F&& visitor) const {
void for_each_prefix_of(const std::basic_string_view<CharT>& key,
F&& visitor) const {
return m_ht.for_each_prefix_of(key.data(), key.size(),
std::forward<F>(visitor));
}
Expand Down
40 changes: 20 additions & 20 deletions tests/trie_map_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,31 +372,31 @@ BOOST_AUTO_TEST_CASE(test_for_each_prefix_of) {
{"abcdf", 1}, {"abcdg", 1}, {"abcdh", 1}, {"babc", 1}};

std::vector<std::pair<const char*, path_type>> 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 << "'");
}
Expand Down

0 comments on commit 2b74e7a

Please sign in to comment.