tbx
0.7.3
|
Simple one way linked list of pointers that provides a single iterator that can be used safely if items are removed or the class containing the list is deleted. More...
#include <safelist.h>
Classes | |
class | Iterator |
Simple class to iterate through the list. More... | |
Public Member Functions | |
SafeList () | |
Construct an empty SafeList. | |
~SafeList () | |
Destructor will clear the list. | |
void | push_back (T *ptr) |
Add pointer to end of list. More... | |
void | remove (T *ptr) |
Remove pointer from list. More... | |
void | clear () |
Empty list. | |
bool | empty () const |
Check if list is empty. | |
Friends | |
class | Iterator |
Simple one way linked list of pointers that provides a single iterator that can be used safely if items are removed or the class containing the list is deleted.
To iterate the list do: SafeList<MyType>::Iterator iter(&my_safe_list) MyType *ptr; while ((ptr = iter.next()) != null) { ptr->my_method(...); }
|
inline |
Add pointer to end of list.
ptr | Pointer to add |
|
inline |
Remove pointer from list.
ptr | to remove |