summaryrefslogtreecommitdiff
path: root/node/Hashtable.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-09-04 13:42:19 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-09-04 13:42:19 -0700
commit7b8ce1605781f14d909e0aa099455b86d738c60a (patch)
treedcd0406f0c3a1f99cf63333ac821bfa414ee7c21 /node/Hashtable.hpp
parent3a959a7763b44ffcddce557167169150a28b9059 (diff)
downloadinfinitytier-7b8ce1605781f14d909e0aa099455b86d738c60a.tar.gz
infinitytier-7b8ce1605781f14d909e0aa099455b86d738c60a.zip
Another std::map<> dies.
Diffstat (limited to 'node/Hashtable.hpp')
-rw-r--r--node/Hashtable.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/node/Hashtable.hpp b/node/Hashtable.hpp
index 84b5be0e..59a57726 100644
--- a/node/Hashtable.hpp
+++ b/node/Hashtable.hpp
@@ -200,6 +200,26 @@ public:
}
/**
+ * Append all keys (in unspecified order) to the supplied vector or list
+ *
+ * @param v Vector, list, or other compliant container
+ * @tparam Type of V (generally inferred)
+ */
+ template<typename C>
+ inline void appendKeys(C &v) const
+ {
+ if (_s) {
+ for(unsigned long i=0;i<_bc;++i) {
+ _Bucket *b = _t[i];
+ while (b) {
+ v.push_back(b->k);
+ b = b->next;
+ }
+ }
+ }
+ }
+
+ /**
* @return Vector of all entries (pairs of K,V)
*/
inline typename std::vector< std::pair<K,V> > entries() const
@@ -235,6 +255,21 @@ public:
inline const V *get(const K &k) const { return const_cast<Hashtable *>(this)->get(k); }
/**
+ * @param k Key to check
+ * @return True if key is present
+ */
+ inline bool contains(const K &k) const
+ {
+ _Bucket *b = _t[_hc(k) % _bc];
+ while (b) {
+ if (b->k == k)
+ return true;
+ b = b->next;
+ }
+ return false;
+ }
+
+ /**
* @param k Key
* @return True if value was present
*/