* Added copyless direct value accessors (via Iterator::NextValue(), and
Get()). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32154 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
696b8f43fb
commit
5174cb1f74
@ -28,12 +28,13 @@
|
||||
#ifndef HASH_MAP_H
|
||||
#define HASH_MAP_H
|
||||
|
||||
//#include <Debug.h>
|
||||
|
||||
#include <Locker.h>
|
||||
|
||||
#include "AutoLocker.h"
|
||||
#include "OpenHashTable.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
// HashMapElement
|
||||
@ -107,7 +108,17 @@ public:
|
||||
_FindNext();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Value* NextValue()
|
||||
{
|
||||
if (fElement == NULL)
|
||||
return NULL;
|
||||
|
||||
Value* value = &fElement->fValue;
|
||||
_FindNext();
|
||||
return value;
|
||||
}
|
||||
|
||||
Entry Remove()
|
||||
{
|
||||
if (!fLastElement)
|
||||
@ -169,6 +180,7 @@ public:
|
||||
Value Remove(const Key& key);
|
||||
void Clear();
|
||||
Value Get(const Key& key) const;
|
||||
bool Get(const Key& key, Value*& _value) const;
|
||||
|
||||
bool ContainsKey(const Key& key) const;
|
||||
|
||||
@ -404,6 +416,19 @@ HashMap<Key, Value>::Get(const Key& key) const
|
||||
return Value();
|
||||
}
|
||||
|
||||
// Get
|
||||
template<typename Key, typename Value>
|
||||
bool
|
||||
HashMap<Key, Value>::Get(const Key& key, Value*& _value) const
|
||||
{
|
||||
if (Element* element = _FindElement(key)) {
|
||||
_value = &element->fValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ContainsKey
|
||||
template<typename Key, typename Value>
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user