MxList refactor (#290)

* MxList refactor

* Reorder LegoPathControllerList::Destroy

* MxPtrList custom destructor and more offsets

Co-authored-by: Christian Semmler <mail@csemmler.com>

* Fix member offset comments in collection classes

* Fix template annotations

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
MS
2023-11-19 07:23:30 -05:00
committed by GitHub
parent 93eb4dc82d
commit 0bb3ea6a03
21 changed files with 308 additions and 170 deletions

View File

@@ -59,16 +59,16 @@ public:
protected:
void _NodeInsert(MxHashTableNode<T>*);
MxHashTableNode<T>** m_slots; // +0x10
MxU32 m_numSlots; // +0x14
MxU32 m_autoResizeRatio; // +0x18
HashTableOpt m_resizeOption; // +0x1c
MxHashTableNode<T>** m_slots; // 0x10
MxU32 m_numSlots; // 0x14
MxU32 m_autoResizeRatio; // 0x18
HashTableOpt m_resizeOption; // 0x1c
// 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
// did it, but a simple cast in either direction doesn't match.
union {
MxU32 m_increaseAmount; // +0x20
double m_increaseFactor; // +0x20
MxU32 m_increaseAmount; // 0x20
double m_increaseFactor; // 0x20
};
};
@@ -156,13 +156,13 @@ void MxHashTable<T>::DeleteAll()
while (t) {
MxHashTableNode<T>* next = t->m_next;
m_customDestructor(t->m_obj);
this->m_customDestructor(t->m_obj);
delete t;
t = next;
}
}
m_count = 0;
this->m_count = 0;
memset(m_slots, 0, sizeof(MxHashTableNode<T>*) * m_numSlots);
delete[] m_slots;
@@ -188,7 +188,7 @@ inline void MxHashTable<T>::Resize()
MxHashTableNode<T>** new_table = new MxHashTableNode<T>*[m_numSlots];
m_slots = new_table;
memset(m_slots, 0, sizeof(MxHashTableNode<T>*) * m_numSlots);
m_count = 0;
this->m_count = 0;
for (MxS32 i = 0; i != old_size; i++) {
MxHashTableNode<T>* t = old_table[i];
@@ -214,13 +214,13 @@ inline void MxHashTable<T>::_NodeInsert(MxHashTableNode<T>* p_node)
m_slots[bucket]->m_prev = p_node;
m_slots[bucket] = p_node;
m_count++;
this->m_count++;
}
template <class T>
inline void MxHashTable<T>::Add(T p_newobj)
{
if (m_resizeOption && ((m_count + 1) / m_numSlots) > m_autoResizeRatio)
if (m_resizeOption && ((this->m_count + 1) / m_numSlots) > m_autoResizeRatio)
MxHashTable<T>::Resize();
MxU32 hash = Hash(p_newobj);