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