summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-01-03 09:47:41 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2018-01-03 09:47:41 +0100
commit3e721962c7f1c7540441e2090f48aee597211aa8 (patch)
tree52f44ad57873429854d0a5389bc529d92d153943 /vespalib
parentb5cfeb6ee3174197bbf9de2978b22a0fc9425ad8 (diff)
Add a comment for rationale.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hash_map.h2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hash_set.h1
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hashtable.h2
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;