Represents a double linked list template with header and tail node. More...
#include <eC_TList_doubleLinked.h>
Public Types | |
typedef bool(* | compare) (T lhs, T rhs) |
compare-function | |
typedef eC_TIterator< T > | Iterator |
Iterator is typedef'd as eC_TIterator ot type T. | |
typedef eC_TSafeIterator< T > | SafeIterator |
SafeIterator is typedef'd as eC_TSafeIterator ot type T. | |
Public Member Functions | |
eC_TListDoubleLinked () | |
eC_TListDoubleLinked (const eC_TListDoubleLinked< T > ©) | |
~eC_TListDoubleLinked () | |
void | Add (const T &tValue) |
void | AddAfter (const T &tValue2Add, Iterator &kIter) |
void | AddAtEnd (const T &tValue) |
void | AddBefore (const T &tValue2Add, Iterator &kIter) |
void | AddSorted (const T &tValue) |
eC_Bool | AddUnique (const T &tValue) |
eC_Bool | AddUniqueAtEnd (const T &tValue) |
eC_Bool | AddUniqueSorted (const T &tValue) |
eC_Bool | Contains (const T &tValue) const |
eC_Bool | Empty () const |
eC_TIterator< T > | GetAt (eC_UInt uiPos) const |
eC_TSafeIterator< T > | GetAtSafe (eC_UInt uiPos) |
eC_TIterator< T > | GetBegin () const |
eC_TSafeIterator< T > | GetBeginSafe () |
eC_TIterator< T > | GetEnd () const |
eC_TSafeIterator< T > | GetEndSafe () |
eC_TIterator< T > | GetFind (const T &tValue) const |
eC_TSafeIterator< T > | GetFindSafe (const T &tValue) |
eC_Bool | GetFirst (T &rtValue) const |
eC_Bool | GetNext (T &rtValue) const |
eC_UInt | GetQuantity () const |
eC_Bool | IsEmpty () const |
eC_Bool | MoveAfter (Iterator &kIter1, Iterator &kIter2) |
eC_Bool | MoveAfter (Iterator &kStartIter, Iterator &kEndIter, Iterator &kIter) |
eC_Bool | MoveBefore (Iterator &kIter1, Iterator &kIter2) |
eC_Bool | MoveBefore (Iterator &kStartIter, Iterator &kEndIter, Iterator &kIter) |
eC_TListDoubleLinked< T > & | operator= (const eC_TListDoubleLinked< T > ©) |
eC_Bool | Remove (const T &tValue) |
eC_Bool | Remove (SafeIterator &kIter) |
void | RemoveAll () |
void | RemoveAll (const T &tValue) |
eC_Bool | RemoveEnd (T &rtValue) |
eC_Bool | RemoveFront (T &rtValue) |
void | ReverseOrder () |
void | Sort (eC_Bool bIsQuicksort=true, compare comp=NULL) |
eC_Bool | Swap (Iterator &kIter1, Iterator &kIter2) |
Friends | |
class | eC_TSafeIterator< T > |
for private access | |
Represents a double linked list template with header and tail node.
The list is not cyclic, i.e. the next element of the last element is NULL and the previous of the front element is NULL.
If the list values were dynamically allocated by the application, it is the application's responsibility to delete those values. This can be done by iterating over the list using the eC_TIterator class and explicitly deleting the values. Use eC_TSafeIterator to delete elements while iterating through the list.
eC_TListDoubleLinked< T >::eC_TListDoubleLinked |
Constructor
eC_TListDoubleLinked< T >::eC_TListDoubleLinked | ( | const eC_TListDoubleLinked< T > & | copy | ) |
Copy constructor.
copy | Where to copy from. |
eC_TListDoubleLinked< T >::~eC_TListDoubleLinked |
Destructor
void eC_TListDoubleLinked< T >::Add | ( | const T & | tValue | ) |
Adds element at front of list
tValue | The value of the node which will be added. |
void eC_TListDoubleLinked< T >::AddAfter | ( | const T & | tValue2Add, |
Iterator & | kIter | ||
) |
Adds element after the Node.
tValue2Add | The value of the node which will be added. |
kIter | Point of the node in the list. |
void eC_TListDoubleLinked< T >::AddAtEnd | ( | const T & | tValue | ) |
Adds element at end of list
tValue | The value of the node which will be added. |
void eC_TListDoubleLinked< T >::AddBefore | ( | const T & | tValue2Add, |
Iterator & | kIter | ||
) |
Adds element at front of the Node.
tValue2Add | The value of the node which will be added. |
kIter | Point of the node in the list. |
void eC_TListDoubleLinked< T >::AddSorted | ( | const T & | tValue | ) |
Adds element sorted into list. Only works useful if existing elements in list are sorted. This function uses operator== and operator>.
tValue | The value of the node which will be added. |
eC_Bool eC_TListDoubleLinked< T >::AddUnique | ( | const T & | tValue | ) |
Adds element at front of list, if list does not already contain this value. This function uses operator==.
tValue | The value of the node which will be added. |
eC_Bool eC_TListDoubleLinked< T >::AddUniqueAtEnd | ( | const T & | tValue | ) |
Adds element at end of list, if list does not already contain this value. This function uses operator==.
tValue | The value of the node which will be added. |
eC_Bool eC_TListDoubleLinked< T >::AddUniqueSorted | ( | const T & | tValue | ) |
Adds element sorted into list, if value does not alredy exist in list. Only works useful if existing elements in list are sorted. This function uses operator== and operator>.
tValue | The value of the node which will be added. |
eC_Bool eC_TListDoubleLinked< T >::Contains | ( | const T & | tValue | ) | const |
Checks if list does contain value of parameter 1 This function uses operator==.
tValue | to be tested for |
eC_Bool eC_TListDoubleLinked< T >::Empty |
Checks if list is empty
|
inline |
Returns an iterator pointing to the element at the specified index.
uiPos | The position index in the list. |
|
inline |
Returns a safe iterator pointing to the element at the specified index.
uiPos | The position index in the list. |
|
inline |
Returns an iterator that points to the first element in the list. Example:
|
inline |
Returns a safe iterator that points to the first element in the list.
|
inline |
Returns an iterator that points to the last element in the list. Example:
|
inline |
Returns a safe iterator that points to the last element in the list.
|
inline |
Returns an iterator that points to a specific value in the list. The list is searched for the first occurrence of the value. An iterator pointing to that list node is returned.
tValue | Value to be found in the list. Example: myIterator=myList.GetFind(Value);
|
|
inline |
Returns a safe iterator that points to a specific value in the list. The list is searched for the first occurrence of the value. A safe iterator pointing to that list node is returned.
tValue | Value to be found in the list. example: myIterator=myList.GetFindSafe(Value); |
eC_Bool eC_TListDoubleLinked< T >::GetFirst | ( | T & | rtValue | ) | const |
With GetFirst and GetNext you can Iterate throug list without using an iterator. GetFirst sets internal pointer to the beginning of the list and returns reference this element.
rtValue | to pop found element into |
eC_Bool eC_TListDoubleLinked< T >::GetNext | ( | T & | rtValue | ) | const |
With GetFirst and GetNext you can iterate through a list without using an iterator. GetNext sets internal pointer to the next list element and returns reference to this element.
rtValue | to pop found element into |
eC_UInt eC_TListDoubleLinked< T >::GetQuantity |
Returns number of elements in list.
eC_Bool eC_TListDoubleLinked< T >::IsEmpty |
Test if the list contains no elements.
eC_Bool eC_TListDoubleLinked< T >::MoveAfter | ( | Iterator & | kIter1, |
Iterator & | kIter2 | ||
) |
Move the element pointed by the first iterator after the second iterator
kIter1,kIter2 | iterators for operation |
eC_Bool eC_TListDoubleLinked< T >::MoveAfter | ( | Iterator & | kStartIter, |
Iterator & | kEndIter, | ||
Iterator & | kIter | ||
) |
Move the elements pointed by the iterators after the second iterator
kStartIter | start of range |
kEndIter | end of range |
kIter | the destination iterator |
eC_Bool eC_TListDoubleLinked< T >::MoveBefore | ( | Iterator & | kIter1, |
Iterator & | kIter2 | ||
) |
Move the element pointed by the first iterator before the second iterator
kIter1,kIter2 | iterators for operation |
eC_Bool eC_TListDoubleLinked< T >::MoveBefore | ( | Iterator & | kStartIter, |
Iterator & | kEndIter, | ||
Iterator & | kIter | ||
) |
Move the elements pointed by the iterators before the second iterator
kStartIter | start of range |
kEndIter | end of range |
kIter | the destination iterator |
|
inline |
Copies the contents of another list to this one. After this operation, this->GetQuantity()==copy.GetQuantity().
copy | The list to copy from. |
eC_Bool eC_TListDoubleLinked< T >::Remove | ( | const T & | tValue | ) |
Removes the first element from list, which is identified by value of parameter 1. This function uses or if not set operator==.
tValue | list element which should be removed |
eC_Bool eC_TListDoubleLinked< T >::Remove | ( | SafeIterator & | kIter | ) |
Removes element which is pointed by SafeIterator.
kIter | A SafeIterator pointing to the element to be removed. |
void eC_TListDoubleLinked< T >::RemoveAll |
Removes all elements of list.
void eC_TListDoubleLinked< T >::RemoveAll | ( | const T & | tValue | ) |
Removes all elements of list wich have the value of parameter1.
tValue | to be removed |
eC_Bool eC_TListDoubleLinked< T >::RemoveEnd | ( | T & | rtValue | ) |
Removes last element of list.
rtValue | to pop removed element into |
eC_Bool eC_TListDoubleLinked< T >::RemoveFront | ( | T & | rtValue | ) |
Removes first element of list.
rtValue | to pop removed element into |
void eC_TListDoubleLinked< T >::ReverseOrder |
Reverses the order of the list. Example: 1-2-3 –> 3-2-1
void eC_TListDoubleLinked< T >::Sort | ( | eC_Bool | bIsQuicksort = true , |
compare | comp = NULL |
||
) |
Sorts list in ascending order. It uses the Quicksort algorithm if the boolean variable is true, otherwise the Mergesort algorithm is utilized. Note that Quicksort is an unstable algorithm. On the other hand, Mergesort is a stable algorithm, thus preserving entrance order if the values are equal.
bIsQuicksort | Whether to use Quicksort |
comp | optional compare-function This function uses operator== and operator>. |
eC_Bool eC_TListDoubleLinked< T >::Swap | ( | Iterator & | kIter1, |
Iterator & | kIter2 | ||
) |
Swappes two elements pointed by iterators or safe iterators.
kIter1,kIter2 | iterators to be swapped |