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:
parent
1419175c27
commit
174b20a89a
@ -20,7 +20,7 @@ class Hashable {
|
|||||||
|
|
||||||
class HashTable {
|
class HashTable {
|
||||||
public:
|
public:
|
||||||
HashTable(int32 capacity = 100, float loadFactor = 0.75);
|
HashTable(bool owning = false, int32 capacity = 100, float loadFactor = 0.75);
|
||||||
~HashTable();
|
~HashTable();
|
||||||
|
|
||||||
void MakeEmpty(bool deleteValues = true);
|
void MakeEmpty(bool deleteValues = true);
|
||||||
@ -42,6 +42,7 @@ class HashTable {
|
|||||||
entry** fTable;
|
entry** fTable;
|
||||||
int32 fCapacity, fCount, fThreshold;
|
int32 fCapacity, fCount, fThreshold;
|
||||||
float fLoadFactor;
|
float fLoadFactor;
|
||||||
|
bool fOwning;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* HASHTABLE_H */
|
#endif /* HASHTABLE_H */
|
||||||
|
@ -22,11 +22,12 @@ struct HashTable::entry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
HashTable::HashTable(int32 capacity, float loadFactor)
|
HashTable::HashTable(bool owning, int32 capacity, float loadFactor)
|
||||||
:
|
:
|
||||||
fTable(NULL),
|
fTable(NULL),
|
||||||
fCount(0),
|
fCount(0),
|
||||||
fThreshold(0)
|
fThreshold(0),
|
||||||
|
fOwning(owning)
|
||||||
{
|
{
|
||||||
if (capacity < 10)
|
if (capacity < 10)
|
||||||
capacity = 10;
|
capacity = 10;
|
||||||
@ -40,7 +41,7 @@ HashTable::HashTable(int32 capacity, float loadFactor)
|
|||||||
|
|
||||||
HashTable::~HashTable()
|
HashTable::~HashTable()
|
||||||
{
|
{
|
||||||
MakeEmpty();
|
MakeEmpty(fOwning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user