Move definitions out of class body

This commit is contained in:
Christian Semmler 2023-09-14 11:59:04 -04:00
parent 68ac78ae03
commit eadacf4e04

View File

@ -75,44 +75,9 @@ class MxListCursor : public MxCore
m_match = NULL; m_match = NULL;
} }
MxBool Find(T *p_obj) { MxBool Find(T *p_obj);
for (m_match = m_list->m_first; void Detach();
m_match && m_list->Compare(m_match->m_obj, p_obj); MxBool Next(T*& p_obj);
m_match = m_match->m_next);
return m_match != NULL;
}
void Detach() {
MxListEntry<T> *m_prev = m_match->m_prev;
MxListEntry<T> *m_next = m_match->m_next;
if (m_prev)
m_prev->m_next = m_next;
else
m_list->m_first = m_next;
if (m_next)
m_next->m_prev = m_prev;
else
m_list->m_last = m_prev;
delete m_match;
m_list->m_count--;
m_match = NULL;
}
MxBool Next(T*& p_obj) {
if (!m_match)
m_match = m_list->m_first;
else
m_match = m_match->m_next;
if (m_match)
p_obj = m_match->m_obj;
return m_match != NULL;
}
private: private:
MxList<T> *m_list; MxList<T> *m_list;
MxListEntry<T> *m_match; MxListEntry<T> *m_match;
@ -170,4 +135,49 @@ inline void MxList<T>::Append(T *p_newobj)
this->m_count++; this->m_count++;
} }
template <class T>
inline MxBool MxListCursor<T>::Find(T *p_obj)
{
for (m_match = m_list->m_first;
m_match && m_list->Compare(m_match->m_obj, p_obj);
m_match = m_match->m_next);
return m_match != NULL;
}
template <class T>
inline void MxListCursor<T>::Detach()
{
MxListEntry<T> *m_prev = m_match->m_prev;
MxListEntry<T> *m_next = m_match->m_next;
if (m_prev)
m_prev->m_next = m_next;
else
m_list->m_first = m_next;
if (m_next)
m_next->m_prev = m_prev;
else
m_list->m_last = m_prev;
delete m_match;
m_list->m_count--;
m_match = NULL;
}
template <class T>
inline MxBool MxListCursor<T>::Next(T*& p_obj)
{
if (!m_match)
m_match = m_list->m_first;
else
m_match = m_match->m_next;
if (m_match)
p_obj = m_match->m_obj;
return m_match != NULL;
}
#endif // MXLIST_H #endif // MXLIST_H