mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-28 18:51:16 +00:00
Refactor HashTableOpt
This commit is contained in:
parent
c6f14e2bd9
commit
a712ff6926
@ -32,10 +32,10 @@ class MxHashTableNode {
|
|||||||
template <class T>
|
template <class T>
|
||||||
class MxHashTable : protected MxCollection<T> {
|
class MxHashTable : protected MxCollection<T> {
|
||||||
public:
|
public:
|
||||||
enum HashTableOpt {
|
enum Option {
|
||||||
HashTableOpt_NoExpand = 0,
|
e_noExpand = 0,
|
||||||
HashTableOpt_ExpandAdd = 1,
|
e_expandAll,
|
||||||
HashTableOpt_ExpandMultiply = 2,
|
e_expandMultiply,
|
||||||
};
|
};
|
||||||
|
|
||||||
MxHashTable()
|
MxHashTable()
|
||||||
@ -43,7 +43,7 @@ class MxHashTable : protected MxCollection<T> {
|
|||||||
m_numSlots = HASH_TABLE_INIT_SIZE;
|
m_numSlots = HASH_TABLE_INIT_SIZE;
|
||||||
m_slots = new MxHashTableNode<T>*[HASH_TABLE_INIT_SIZE];
|
m_slots = new MxHashTableNode<T>*[HASH_TABLE_INIT_SIZE];
|
||||||
memset(m_slots, 0, sizeof(MxHashTableNode<T>*) * m_numSlots);
|
memset(m_slots, 0, sizeof(MxHashTableNode<T>*) * m_numSlots);
|
||||||
m_resizeOption = HashTableOpt_NoExpand;
|
m_resizeOption = e_noExpand;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~MxHashTable() override;
|
virtual ~MxHashTable() override;
|
||||||
@ -62,7 +62,7 @@ class MxHashTable : protected MxCollection<T> {
|
|||||||
MxHashTableNode<T>** m_slots; // 0x10
|
MxHashTableNode<T>** m_slots; // 0x10
|
||||||
MxU32 m_numSlots; // 0x14
|
MxU32 m_numSlots; // 0x14
|
||||||
MxU32 m_autoResizeRatio; // 0x18
|
MxU32 m_autoResizeRatio; // 0x18
|
||||||
HashTableOpt m_resizeOption; // 0x1c
|
Option m_resizeOption; // 0x1c
|
||||||
// FIXME: or FIXME? This qword is used as an integer or double depending
|
// FIXME: or FIXME? This qword is used as an integer or double depending
|
||||||
// on the value of m_resizeOption. Hard to say whether this is how the devs
|
// on the value of m_resizeOption. Hard to say whether this is how the devs
|
||||||
// did it, but a simple cast in either direction doesn't match.
|
// did it, but a simple cast in either direction doesn't match.
|
||||||
@ -177,10 +177,10 @@ inline void MxHashTable<T>::Resize()
|
|||||||
MxHashTableNode<T>** oldTable = m_slots;
|
MxHashTableNode<T>** oldTable = m_slots;
|
||||||
|
|
||||||
switch (m_resizeOption) {
|
switch (m_resizeOption) {
|
||||||
case HashTableOpt_ExpandAdd:
|
case e_expandAll:
|
||||||
m_numSlots += m_increaseAmount;
|
m_numSlots += m_increaseAmount;
|
||||||
break;
|
break;
|
||||||
case HashTableOpt_ExpandMultiply:
|
case e_expandMultiply:
|
||||||
m_numSlots *= m_increaseFactor;
|
m_numSlots *= m_increaseFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user