#include <plist.h>
Inheritance diagram for TPList:
Public Types | |
typedef list< X *>::iterator | iterator |
typedef list< X *>::const_iterator | const_iterator |
Public Methods | |
TPList (bool autoDelete=false) | |
TPList (const TPList< X > &src) | |
virtual | ~TPList () |
void | add (X *obj) |
void | deleteAll () |
iterator | find (X *obj) |
X * | getFirst () const |
iterator | goTo (int4 n) |
TPList< X > & | operator= (const TPList &Src) |
bool | remove (X *obj) |
bool | remove (iterator it) |
void | setAutoDeleteMode (bool autoDelete) |
Protected Attributes | |
bool | fAutoDelete |
Example:
TPList<TSubFleet> fSubFleets; fSubFleets.setAutoDeleteMode( true ); subFleet = new TSubFleet(...); fSubFleets.push_back( subFleet ); fSubFleets.push_back( new TSubFleet(...) ); fSubFleets.remove( subFleet ); // <= also deltes the subFleet itself!
So usage is similar to a list. Note though the remove command and that a destructor call of TPList<...> also deletes all objects if the "auto delete mode" is set to true.
|
The constructor initializes the auto delete variable (SetAutoDeleteMode).
|
|
The destructor calls deleteAll to clean up everything. |
|
Adds a object to the list. Note this method is doing the same as the list method "push_back". There is no check which prevents adding the same object twice.
|
|
Deletes all elements from the list.
|
|
|
|
|
|
Returns the iterator for the n-th element. Note: this operation is slow O(n).
|
|
The operator= copies the pointer list, but not the variable fAutoDelete. fAutoDelete is not copied, but set to
|
|
Removes an object from the list. Note that this method is the same as
|
|
Removes an object from the list. Note that this method is the same as
|
|
Sets the auto delete mode (see fAutoDelete for details).
|
|
If set to |