Skip to content

Commit

Permalink
Adds node removal functionality to tlist type.
Browse files Browse the repository at this point in the history
  • Loading branch information
SkylineR390 committed Apr 11, 2024
1 parent 4888873 commit fd3502d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions skse64/GameTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,16 @@ class tList
m_listHead.item = item;
}

bool Remove(T *item)
{
_Node *prev = nullptr;
_Node *curr = &m_listHead;

while (curr && (*curr).item != item)
prev = curr, curr = (*curr).next;
return (curr && (*curr).Remove(prev) );
}

void Push(T * item)
{
_Node * tail = Tail();
Expand Down Expand Up @@ -822,11 +832,11 @@ class tList
{
T* pRemoved = NULL;
if (n == 0) {
pRemoved = m_listHead.RemoveMe();
pRemoved = m_listHead.Remove(nullptr);
} else if (n > 0) {
NodePos nodePos = GetNthNode(n);
if (nodePos.node && nodePos.index == n) {
pRemoved = nodePos.node->RemoveMe();
pRemoved = nodePos.node->Remove(GetNthNode(n - 1).node);
}
}
return pRemoved;
Expand Down

0 comments on commit fd3502d

Please sign in to comment.