Another std::map<> dies.
This commit is contained in:
parent
3a959a7763
commit
7b8ce16057
4 changed files with 50 additions and 10 deletions
|
@ -199,6 +199,26 @@ public:
|
|||
return k;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
|
@ -234,6 +254,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue