mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-01-12 23:08:03 +03:00
sync
This commit is contained in:
parent
44db80bc75
commit
cb291dbdd5
@ -48,12 +48,12 @@ public:
|
||||
typedef List<THashNode *> * NodePtr;
|
||||
public:
|
||||
class const_iterator;
|
||||
THash() : m_Buckets(NULL), m_numBuckets(0), m_percentUsed(0.0f), m_NumItems(0)
|
||||
THash() : m_Buckets(NULL), m_numBuckets(0), m_percentUsed(0.0f), m_items(0)
|
||||
{
|
||||
_Refactor();
|
||||
}
|
||||
THash(const THash &other) : m_Buckets(new NodePtr[other.m_numBuckets]),
|
||||
m_numBuckets(other.m_numBuckets), m_percentUsed(other.m_percentUsed)
|
||||
m_numBuckets(other.m_numBuckets), m_percentUsed(other.m_percentUsed), m_items(0)
|
||||
{
|
||||
for (size_t i=0; i<m_numBuckets; i++)
|
||||
m_Buckets[i] = NULL;
|
||||
@ -76,6 +76,10 @@ public:
|
||||
_Clear();
|
||||
_Refactor();
|
||||
}
|
||||
size_t size()
|
||||
{
|
||||
return m_items;
|
||||
}
|
||||
size_t GetBuckets()
|
||||
{
|
||||
return m_numBuckets;
|
||||
@ -84,10 +88,6 @@ public:
|
||||
{
|
||||
return m_percentUsed;
|
||||
}
|
||||
size_t size()
|
||||
{
|
||||
return m_NumItems;
|
||||
}
|
||||
V & operator [](const K & key)
|
||||
{
|
||||
THashNode *pNode = _FindOrInsert(key);
|
||||
@ -116,7 +116,7 @@ private:
|
||||
delete [] m_Buckets;
|
||||
m_Buckets = NULL;
|
||||
m_numBuckets = 0;
|
||||
m_NumItems = 0;
|
||||
m_items = 0;
|
||||
}
|
||||
THashNode *_FindOrInsert(const K & key)
|
||||
{
|
||||
@ -128,7 +128,7 @@ private:
|
||||
pNode = new THashNode(key, V());
|
||||
m_Buckets[place]->push_back(pNode);
|
||||
m_percentUsed += (1.0f / (float)m_numBuckets);
|
||||
m_NumItems++;
|
||||
m_items++;
|
||||
} else {
|
||||
typename List<THashNode *>::iterator iter;
|
||||
for (iter=m_Buckets[place]->begin(); iter!=m_Buckets[place]->end(); iter++)
|
||||
@ -139,7 +139,7 @@ private:
|
||||
//node does not exist
|
||||
pNode = new THashNode(key, V());
|
||||
m_Buckets[place]->push_back(pNode);
|
||||
m_NumItems++;
|
||||
m_items++;
|
||||
}
|
||||
if (PercentUsed() > 0.75f)
|
||||
_Refactor();
|
||||
@ -267,9 +267,10 @@ public:
|
||||
delete (*iter);
|
||||
hash->m_Buckets[curbucket]->erase(iter);
|
||||
*this = tmp;
|
||||
m_NumItems--;
|
||||
|
||||
// :TODO: Maybe refactor to a lower size if required
|
||||
|
||||
m_items--;
|
||||
}
|
||||
private:
|
||||
void _Inc()
|
||||
@ -483,7 +484,7 @@ private:
|
||||
NodePtr *m_Buckets;
|
||||
size_t m_numBuckets;
|
||||
float m_percentUsed;
|
||||
size_t m_NumItems;
|
||||
size_t m_items;
|
||||
};
|
||||
//};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user