diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-04 11:50:12 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-04 11:50:12 -0700 |
commit | cfd101c9b85b20e5911445998a6f040089e3e414 (patch) | |
tree | cf5ecd343a35da6343738c6a9ee2e50df2b87c28 | |
parent | da9a720c3fc2d69e35f393fbb96a716599ac0a6f (diff) | |
download | infinitytier-cfd101c9b85b20e5911445998a6f040089e3e414.tar.gz infinitytier-cfd101c9b85b20e5911445998a6f040089e3e414.zip |
Add entries() to go with keys() for future use.
-rw-r--r-- | node/Hashtable.hpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/node/Hashtable.hpp b/node/Hashtable.hpp index 5076751d..6f7541c4 100644 --- a/node/Hashtable.hpp +++ b/node/Hashtable.hpp @@ -30,6 +30,8 @@ #include <stdexcept> #include <vector> +#include <utility> +#include <algorithm> namespace ZeroTier { @@ -197,6 +199,24 @@ public: } /** + * @return Vector of all entries (pairs of K,V) + */ + inline typename std::vector< std::pair<K,V> > entries() + { + typename std::vector< std::pair<K,V> > k; + if (_s) { + for(unsigned long i=0;i<_bc;++i) { + _Bucket *b = _t[i]; + while (b) { + k.push_back(std::pair<K,V>(b->k,b->v)); + b = b->next; + } + } + } + return k; + } + + /** * @param k Key * @return Pointer to value or NULL if not found */ |