An iterator that stays valid even if elements are deleted from the list. More...
#include <eC_TList_Iterators.h>
Public Member Functions | |
eC_TSafeIterator () | |
eC_TSafeIterator (const eC_TSafeIterator< T > &kIter) | |
virtual eC_Bool | IsInsideList () const |
eC_Bool | IsNextValid () const |
eC_Bool | IsPreviousValid () const |
eC_Bool | operator!= (const eC_TSafeIterator &kIter) |
eC_TSafeIterator & | operator++ () |
eC_TSafeIterator & | operator-- () |
eC_TSafeIterator & | operator= (const eC_TSafeIterator &kIter) |
eC_Bool | operator== (const eC_TSafeIterator &kIter) const |
![]() | |
eC_TIterator () | |
eC_TIterator (const eC_TIterator< T > &x) | |
eC_TIterator (Node *pNode) | |
virtual | ~eC_TIterator () |
Destructor. | |
virtual eC_Bool | IsInsideList () const |
eC_Bool | IsValid () const |
eC_Bool | operator!= (const eC_TIterator &kIter) const |
T & | operator* () |
eC_TIterator & | operator++ () |
eC_TIterator | operator++ (int) |
eC_TIterator & | operator-- () |
eC_TIterator | operator-- (int) |
eC_TIterator & | operator= (const eC_TIterator &kIter) |
eC_Bool | operator== (const eC_TIterator &kIter) const |
eC_Bool | operator== (const Node *const ptrNode) const |
Friends | |
class | eC_TListDoubleLinked< T > |
Additional Inherited Members | |
![]() | |
typedef ListNode< T > | Node |
typedef for node | |
![]() | |
Node * | GetNode () const |
![]() | |
Node * | m_pNode |
this node More... | |
An iterator that stays valid even if elements are deleted from the list.
With safe iterators it is possible to remove elements while iterating through a list.
With IsValid() it can be tested if the iterator may be dereferenced. If an item is deleted, the iterator is invalid, but you can still iterate through the list. After the next step (increment or decrement) the iterator is valid again (until you remove another element). After sorting and eC_TListDoubleLinked<T>::RemoveAll() all safe iterators are invalid and have to be set again.
Example:
If you remove an item and add one at the position of the removed element (in one iteration step) it is possible that the new element is "lost" in that iteration.
Example
3-5-8
5 is deleted 7 is added
3-7-8
In this case 7 will be "lost" if iterator pointed at 5, because iterator is now pointing at 7, and after next iteration step it will be pointing at 8.
Note: This iterator does not have postfix increment/decrement operators because implementing them for the current approach for this safe iterator is not effective.
|
inline |
Constructor needs pointer to list, iterator will be used with. This is necessary to register iterator in this list, so that iterators can be updated if list is modified.
|
inline |
Copy constructor.
kIter | Where to copy from |
|
inlinevirtual |
!DO NOT USE WHEN ITERATING BACKWARDS AND DELETING NODES! Use FOR_ALL_BACKWARD_SAFE instead. Used to test if iterator is not pointing beyond list.
Reimplemented from eC_TIterator< T >.
|
inline |
|
inline |
|
inline |
Used to compare two Iterators.
kIter | What to compare with |
|
inline |
Used to increment Iterator. Prefix version. Iterator is pointing to next list element.
|
inline |
Used to decrement Iterator. Prefix version. Iterator is pointing to previous list element.
|
inline |
Assignment operator.
kIter | Where to copy from |
|
inline |
Used to compare two iterators.
kIter | What to compare with |