mirror of
https://github.com/zeldaret/tww.git
synced 2026-09-12 04:19:04 -04:00
linklist match
stolen from Cuyler & ac-decomp
This commit is contained in:
@@ -38,6 +38,7 @@ struct TNodeLinkList {
|
||||
|
||||
struct const_iterator {
|
||||
const_iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
const_iterator(iterator it) { node = it.node; }
|
||||
|
||||
const_iterator& operator++() { node = node->getNext(); return *this; }
|
||||
const_iterator& operator--() { node = node->getPrev(); return *this; }
|
||||
@@ -76,6 +77,26 @@ struct TNodeLinkList {
|
||||
iterator Erase(JGadget::TLinkListNode*);
|
||||
void Remove(JGadget::TLinkListNode*);
|
||||
|
||||
bool Iterator_isEnd_(const_iterator it) const { return it.node == &ocObject_; }
|
||||
template <typename Predicate> void Remove_if(Predicate predicate, TNodeLinkList& tList) {
|
||||
iterator it = begin();
|
||||
|
||||
while (!Iterator_isEnd_(it)) {
|
||||
if (predicate(*it)) {
|
||||
iterator itPrev = it;
|
||||
++it;
|
||||
tList.splice(tList.end(), *this, itPrev);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Predicate> void remove_if(Predicate predicate) {
|
||||
TNodeLinkList list;
|
||||
Remove_if(predicate, list);
|
||||
}
|
||||
|
||||
public:
|
||||
/* 0x00 */ u32 count;
|
||||
/* 0x04 */ TLinkListNode ocObject_;
|
||||
|
||||
Reference in New Issue
Block a user