#include <iostream>
#include "abacus/abacusroot.h"
#include "abacus/global.h"
#include "abacus/dlistitem.h"
#include "abacus/dlist.inc"
Go to the source code of this file.
Classes | |
class | ABA_DLIST< Type > |
class ABA_DLIST implements a doubly linked linear list. The list is implemented by a doubly linked list of ABA_DLISTITEMs. More... | |
Defines | |
#define | forAllDListElem(L, item, e) |
ABA_DLIST: iterators. |
The following sections implement a template for a doubly linked linear list. The implementation is very similar to the class ABA_LIST. However, we do not derive these classes from the respective classes of ABA_LIST since this causes type conflicts. (e.g. {item->pred_->succ_ = dListItem} would require explicit cast).
Definition in file dlist.h.
#define forAllDListElem | ( | L, | |||
item, | |||||
e | ) |
Value:
for((item = (L).first()) ? (e = (item)->elem()) : 0; item !=0; \
(item = (item)->succ()) ? (e = (item)->elem()) : 0)
The iterator forAllDListElem assigns to {Type e} all elements in the list beginning with the first element. The additional parameter item has to be of type ABA_DLISTITEM<Type>*. Deletions of elements in the list during the application of this iterator can cause an error. The operator ?: is used that item is only dereferenced if item != 0. The expression 0 on the right side of : is only a dummy that this expression is compilable.
L | The list that should be iterated (ABA_DLIST<Type>). | |
item | An auxilliary pointer to a list item (ABA_DLISTITEM<Type> *). | |
e | The elements in the list are assigned to this variable (Type). |