diff options
-rw-r--r-- | vespalib/src/vespa/vespalib/stllike/hash_map.h | 2 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/stllike/hash_set.h | 1 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/stllike/hashtable.h | 2 |
3 files changed, 5 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.h b/vespalib/src/vespa/vespalib/stllike/hash_map.h index f00b7ec224d..f2431a73f28 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.h +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.h @@ -38,6 +38,8 @@ public: insert_result insert(const value_type & value) { return _ht.insert(value); } template <typename InputIt> void insert(InputIt first, InputIt last); + + /// This gives faster iteration than can be achieved by the iterators. template <typename Func> void for_each(Func func) const { _ht.for_each(func); } const V & operator [] (const K & key) const { return _ht.find(key)->second; } diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set.h b/vespalib/src/vespa/vespalib/stllike/hash_set.h index a8d855d5ddd..bb16932a990 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_set.h +++ b/vespalib/src/vespa/vespalib/stllike/hash_set.h @@ -43,6 +43,7 @@ public: iterator find(const K & key) { return _ht.find(key); } const_iterator find(const K & key) const { return _ht.find(key); } + /// This gives faster iteration than can be achieved by the iterators. template <typename Func> void for_each(Func func) const { _ht.for_each(func); } diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.h b/vespalib/src/vespa/vespalib/stllike/hashtable.h index 41781e649f3..16d9cde1f78 100644 --- a/vespalib/src/vespa/vespalib/stllike/hashtable.h +++ b/vespalib/src/vespa/vespalib/stllike/hashtable.h @@ -249,6 +249,8 @@ public: insert_result insert(V && node) { return insertInternal(std::forward<V>(node)); } + + /// This gives faster iteration than can be achieved by the iterators. template <typename Func> void for_each(Func func) const; |