tbx  0.7.5
Classes | Public Member Functions | Friends | List of all members
tbx::SafeList< T > Class Template Reference

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
 

Detailed Description

template<class T>
class tbx::SafeList< T >

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(...); }

Member Function Documentation

◆ push_back()

template<class T>
void tbx::SafeList< T >::push_back ( T *  ptr)
inline

Add pointer to end of list.

Parameters
ptrPointer to add

◆ remove()

template<class T>
void tbx::SafeList< T >::remove ( T *  ptr)
inline

Remove pointer from list.

Parameters
ptrto remove

The documentation for this class was generated from the following file: