42 operator TBLink *()
const {
return m_current_link; }
44 const TBLinkListIterator& operator = (
const TBLinkListIterator &iter);
46 TBLinkList *m_linklist;
47 TBLink *m_current_link;
50 TBLinkListIterator *m_prev;
51 TBLinkListIterator *m_next;
55 void RemoveLink(TBLink *link);
56 friend class TBLinkList;
63 void UnregisterAndClear();
72 TBLink() : prev(
nullptr), next(
nullptr), linklist(
nullptr) {}
75 bool IsInList()
const {
return linklist ?
true :
false; }
86 inline T *GetPrev()
const {
return (T *) prev; }
87 inline T *GetNext()
const {
return (T *) next; }
96 TBLinkList() : first(
nullptr), last(
nullptr), first_iterator(
nullptr) {}
102 void AddFirst(
TBLink *link);
103 void AddLast(
TBLink *link);
108 bool ContainsLink(
TBLink *link)
const {
return link->linklist ==
this; }
110 bool HasLinks()
const {
return first ?
true :
false; }
112 int CountLinks()
const;
159 bool HasLinks()
const {
return m_linklist.HasLinks(); }
169 :
TBLinkListIterator(&linklistof->m_linklist, forward ? linklistof->m_linklist.first : linklistof->m_linklist.last, forward) {}
173 inline operator T *()
const {
return (T *)
static_cast<TBLinkOf<T>*
>(Get()); }
202 #endif // TB_LINKLIST_H
T * GetLast() const
Get the last link, or nullptr.
Definition: tb_linklist.h:156
TBLinkListOf is a double linked linklist.
Definition: tb_linklist.h:122
void Delete(T *link)
Remove link from this linklist and delete it.
Definition: tb_linklist.h:129
T * GetFirst() const
Get the first link, or nullptr.
Definition: tb_linklist.h:153
Iterator IterateForward()
Get a forward iterator that starts with the first link.
Definition: tb_linklist.h:177
TBLinkList - This is the backend for TBLinkListOf and TBLinkListAutoDeleteOf.
Definition: tb_linklist.h:93
TBLink * Get() const
Get the current link or nullptr if out of bounds.
Definition: tb_linklist.h:37
void AddLast(T *link)
Add link last in this linklist.
Definition: tb_linklist.h:141
Iterator IterateBackward(T *link)
Get a backward iterator that starts with the given link.
Definition: tb_linklist.h:186
void Reset()
Set the iterator to the first link in we iterate forward, or set it to the last link if we iterate ba...
Definition: tb_linklist.cpp:78
void RemoveAll()
Remove all links without deleting them.
Definition: tb_linklist.h:132
bool IsInList() const
Return true if the link is currently added to a list.
Definition: tb_linklist.h:75
Typed iterator for safe iteration.
Definition: tb_linklist.h:165
bool HasLinks() const
Return true if this linklist contains any links.
Definition: tb_linklist.h:159
TBLink * GetAndStep()
Get the current link and step the iterator to the next (forward or backward).
Definition: tb_linklist.cpp:86
int CountLinks() const
Count the number of links in this list by iterating through all links.
Definition: tb_linklist.h:162
bool ContainsLink(T *link) const
Return true if the link is currently added to this linklist.
Definition: tb_linklist.h:150
void DeleteAll()
Delete all links in this linklist.
Definition: tb_linklist.h:135
void Remove(T *link)
Remove link from this linklist.
Definition: tb_linklist.h:126
Iterator IterateBackward()
Get a backward iterator that starts with the last link.
Definition: tb_linklist.h:183
TBLinkListAutoDeleteOf is a double linked linklist that deletes all links on destruction.
Definition: tb_linklist.h:194
Definition: tb_linklist.h:83
void AddAfter(T *link, T *reference)
Add link after the reference link (which must be added to this linklist).
Definition: tb_linklist.h:147
TBLinkListIterator - The backend class for a safe iteration of a TBLinkList.
Definition: tb_linklist.h:25
void AddBefore(T *link, T *reference)
Add link before the reference link (which must be added to this linklist).
Definition: tb_linklist.h:144
void AddFirst(T *link)
Add link first in this linklist.
Definition: tb_linklist.h:138
Iterator IterateForward(T *link)
Get a forward iterator that starts with the given link.
Definition: tb_linklist.h:180
TBLink - The backend class to be inserted in TBLinkList.
Definition: tb_linklist.h:69