mirror of https://github.com/zeldaret/tp.git
Minor linklist.h debug fixes (#2887)
This commit is contained in:
parent
c974c979ee
commit
3e8442dcbd
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "JSystem/JGadget/define.h"
|
||||
#include "JSystem/JGadget/search.h"
|
||||
#include <iterator.h>
|
||||
|
||||
|
||||
namespace JGadget {
|
||||
struct TLinkListNode {
|
||||
TLinkListNode() {
|
||||
|
|
@ -117,19 +119,27 @@ public:
|
|||
}; // Size: 0xC
|
||||
|
||||
template <typename T, int I>
|
||||
struct TLinkList : public TNodeLinkList {
|
||||
struct TLinkList : TNodeLinkList {
|
||||
TLinkList() : TNodeLinkList() {}
|
||||
|
||||
struct iterator {
|
||||
struct iterator : TNodeLinkList::iterator {
|
||||
iterator() {}
|
||||
explicit iterator(TNodeLinkList::iterator iter) : base(iter) {}
|
||||
explicit iterator(TNodeLinkList::iterator iter) : TNodeLinkList::iterator(iter) {}
|
||||
|
||||
iterator& operator=(const iterator& rhs) {
|
||||
//TODO: Probably fakematch? Not sure what's going on here exactly
|
||||
(TIterator<std::bidirectional_iterator_tag, T, long, T*, T&>&)*this =
|
||||
(const TIterator<std::bidirectional_iterator_tag, T, long, T*, T&>&)rhs;
|
||||
this->node = rhs.node;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator& operator++() {
|
||||
++base;
|
||||
TNodeLinkList::iterator::operator++();
|
||||
return *this;
|
||||
}
|
||||
iterator& operator--() {
|
||||
--base;
|
||||
TNodeLinkList::iterator::operator--();
|
||||
return *this;
|
||||
}
|
||||
iterator operator++(int) {
|
||||
|
|
@ -142,10 +152,12 @@ struct TLinkList : public TNodeLinkList {
|
|||
--*this;
|
||||
return old;
|
||||
}
|
||||
friend bool operator==(iterator a, iterator b) { return a.base == b.base; }
|
||||
friend bool operator==(iterator a, iterator b) {
|
||||
return (TNodeLinkList::iterator&)a == (TNodeLinkList::iterator&)b;
|
||||
}
|
||||
friend bool operator!=(iterator a, iterator b) { return !(a == b); }
|
||||
|
||||
T* operator->() const { return Element_toValue(base.operator->()); }
|
||||
T* operator->() const { return Element_toValue(TNodeLinkList::iterator::operator->()); }
|
||||
T& operator*() const {
|
||||
T* p = operator->();
|
||||
JUT_ASSERT(541, p!=NULL);
|
||||
|
|
@ -157,21 +169,20 @@ struct TLinkList : public TNodeLinkList {
|
|||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
|
||||
public:
|
||||
/* 0x00 */ TNodeLinkList::iterator base;
|
||||
};
|
||||
|
||||
struct const_iterator {
|
||||
explicit const_iterator(TNodeLinkList::const_iterator iter) : base(iter) {}
|
||||
explicit const_iterator(iterator iter) : base(iter.base) {}
|
||||
struct const_iterator : TNodeLinkList::const_iterator {
|
||||
explicit const_iterator(TNodeLinkList::const_iterator iter) :
|
||||
TNodeLinkList::const_iterator(iter) {}
|
||||
explicit const_iterator(iterator iter) :
|
||||
TNodeLinkList::const_iterator((TNodeLinkList::iterator&)iter) {}
|
||||
|
||||
const_iterator& operator++() {
|
||||
++base;
|
||||
TNodeLinkList::const_iterator::operator++();
|
||||
return *this;
|
||||
}
|
||||
const_iterator& operator--() {
|
||||
--base;
|
||||
TNodeLinkList::const_iterator::operator++();
|
||||
return *this;
|
||||
}
|
||||
const_iterator operator++(int) {
|
||||
|
|
@ -184,14 +195,17 @@ struct TLinkList : public TNodeLinkList {
|
|||
--*this;
|
||||
return old;
|
||||
}
|
||||
friend bool operator==(const_iterator a, const_iterator b) { return a.base == b.base; }
|
||||
friend bool operator==(const_iterator a, const_iterator b) {
|
||||
return (TNodeLinkList::const_iterator&)a == (TNodeLinkList::const_iterator&)b;
|
||||
}
|
||||
friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
|
||||
|
||||
const T* operator->() const { return Element_toValue(base.operator->()); }
|
||||
const T& operator*() const { return *operator->(); }
|
||||
|
||||
public:
|
||||
/* 0x00 */ TNodeLinkList::const_iterator base;
|
||||
const T* operator->() const { return Element_toValue(TNodeLinkList::const_iterator::operator->()); }
|
||||
const T& operator*() const {
|
||||
const T* p = &*operator->();
|
||||
JUT_ASSERT(0x24a, p!=NULL);
|
||||
return *p;
|
||||
}
|
||||
};
|
||||
|
||||
static TLinkListNode* Element_toNode(T* p) {
|
||||
|
|
@ -212,7 +226,7 @@ struct TLinkList : public TNodeLinkList {
|
|||
}
|
||||
|
||||
iterator Insert(iterator iter, T* element) {
|
||||
return iterator(TNodeLinkList::Insert(iter.base, Element_toNode(element)));
|
||||
return iterator(TNodeLinkList::Insert((TNodeLinkList::iterator&)iter, Element_toNode(element)));
|
||||
}
|
||||
iterator Erase(T* element) { return iterator(TNodeLinkList::Erase(Element_toNode(element))); }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue