Adds the concept of owning the table entries - before, they were always owned,

now it defaults to not-owning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14823 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-10 14:49:24 +00:00
parent 1419175c27
commit 174b20a89a
2 changed files with 6 additions and 4 deletions

View File

@ -20,7 +20,7 @@ class Hashable {
class HashTable {
public:
HashTable(int32 capacity = 100, float loadFactor = 0.75);
HashTable(bool owning = false, int32 capacity = 100, float loadFactor = 0.75);
~HashTable();
void MakeEmpty(bool deleteValues = true);
@ -42,6 +42,7 @@ class HashTable {
entry** fTable;
int32 fCapacity, fCount, fThreshold;
float fLoadFactor;
bool fOwning;
};
#endif /* HASHTABLE_H */

View File

@ -22,11 +22,12 @@ struct HashTable::entry {
};
HashTable::HashTable(int32 capacity, float loadFactor)
HashTable::HashTable(bool owning, int32 capacity, float loadFactor)
:
fTable(NULL),
fCount(0),
fThreshold(0)
fThreshold(0),
fOwning(owning)
{
if (capacity < 10)
capacity = 10;
@ -40,7 +41,7 @@ HashTable::HashTable(int32 capacity, float loadFactor)
HashTable::~HashTable()
{
MakeEmpty();
MakeEmpty(fOwning);
}