Add entries() to go with keys() for future use.

This commit is contained in:
Adam Ierymenko 2015-09-04 11:50:12 -07:00
parent da9a720c3f
commit cfd101c9b8

View File

@ -30,6 +30,8 @@
#include <stdexcept>
#include <vector>
#include <utility>
#include <algorithm>
namespace ZeroTier {
@ -196,6 +198,24 @@ public:
return k;
}
/**
* @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