25 #ifndef TBX_SAFELIST_H
26 #define TBX_SAFELIST_H
49 Node(T *ptr) : _ptr(ptr), _next(0) {};
108 friend class Iterator;
128 if (_head == 0) _head =
new Node(ptr);
132 while (last->_next != 0) last = last->_next;
133 last->_next =
new Node(ptr);
146 while (check && check->_ptr != ptr)
149 check = check->_next;
153 if (prev) prev->_next = check->_next;
154 else _head = check->_next;
156 if (_iter && _iter->_next == check)
158 _iter->_next = check->_next;
169 if (_iter) _iter->_next = 0;
void clear()
Empty list.
Definition: safelist.h:167
void push_back(T *ptr)
Add pointer to end of list.
Definition: safelist.h:126
Simple one way linked list of pointers that provides a single iterator that can be used safely if ite...
Definition: safelist.h:44
Simple class to iterate through the list.
Definition: safelist.h:62
SafeList()
Construct an empty SafeList.
Definition: safelist.h:114
Iterator(SafeList &list)
Construct the iterator for the list.
Definition: safelist.h:74
T * next()
Get next pointer from the list.
Definition: safelist.h:87
bool empty() const
Check if list is empty.
Definition: safelist.h:184
~SafeList()
Destructor will clear the list.
Definition: safelist.h:119