diff options
author | Evan Brown <ezb@google.com> | 2023-08-17 13:31:24 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-08-17 13:32:40 -0700 |
commit | 76af16444ed33791223b3c123d311ab699f1df01 (patch) | |
tree | b52654aa94e84c7c7b6185f2a4e3b0b160240472 /absl/container/internal/raw_hash_set.h | |
parent | 88ed1832745ab8cc3aa9cc6ccc40f87ffbd6c9f9 (diff) |
Remove the has_element function and use FindElement instead.
PiperOrigin-RevId: 557920808
Change-Id: I1eb0ca1ea9e9de542321fbc23d82218c5d449fbf
Diffstat (limited to 'absl/container/internal/raw_hash_set.h')
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 678ed7ea..f4cf8367 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -2453,8 +2453,10 @@ class raw_hash_set { const raw_hash_set* outer = &a; const raw_hash_set* inner = &b; if (outer->capacity() > inner->capacity()) std::swap(outer, inner); - for (const value_type& elem : *outer) - if (!inner->has_element(elem)) return false; + for (const value_type& elem : *outer) { + auto it = PolicyTraits::apply(FindElement{*inner}, elem); + if (it == inner->end() || !(*it == elem)) return false; + } return true; } @@ -2659,24 +2661,6 @@ class raw_hash_set { } } - bool has_element(const value_type& elem) const { - size_t hash = PolicyTraits::apply(HashElement{hash_ref()}, elem); - auto seq = probe(common(), hash); - const ctrl_t* ctrl = control(); - while (true) { - Group g{ctrl + seq.offset()}; - for (uint32_t i : g.Match(H2(hash))) { - if (ABSL_PREDICT_TRUE( - PolicyTraits::element(slot_array() + seq.offset(i)) == elem)) - return true; - } - if (ABSL_PREDICT_TRUE(g.MaskEmpty())) return false; - seq.next(); - assert(seq.index() <= capacity() && "full table!"); - } - return false; - } - // TODO(alkis): Optimize this assuming *this and that don't overlap. raw_hash_set& move_assign(raw_hash_set&& that, std::true_type) { raw_hash_set tmp(std::move(that)); |