From 9f93631c4797a48cb6f9f870f2b90b250b50c135 Mon Sep 17 00:00:00 2001 From: Chris Dodd Date: Fri, 23 Feb 2024 19:39:01 +1300 Subject: [PATCH] add hvec_map::count method --- lib/hvec_map.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/hvec_map.h b/lib/hvec_map.h index 3ca30a8585e..19117ccf78b 100644 --- a/lib/hvec_map.h +++ b/lib/hvec_map.h @@ -169,6 +169,11 @@ class hvec_map : hash_vector_base { size_t idx = hash_vector_base::find(&k, &cache); return idx ? const_iterator(*this, idx - 1) : end(); } + size_t count(const KEY &k) const { + hash_vector_base::lookup_cache cache; + size_t idx = hash_vector_base::find(&k, &cache); + return idx > 0; + } // FIXME -- how to do this without duplicating the code for lvalue/rvalue? VAL &operator[](const KEY &k) {