#include <iostream>
#include "abacus/abacusroot.h"
#include "abacus/global.h"
#include "abacus/listitem.h"
#include "abacus/list.inc"
Go to the source code of this file.
Classes | |
class | ABA_LIST< Type > |
class ABA_LIST More... | |
Defines | |
#define | forAllListElem(L, item, e) |
ABA_LIST: iterators. |
The following sections implement a template for a linked linear list. Two classes are required for the representation of this data structure. The first one ABA_LISTITEM forms the basic building block of the list storing an element and a pointer to the next item of the list, the second one is the ABA_LIST itself.
Definition in file list.h.
#define forAllListElem | ( | L, | |||
item, | |||||
e | ) |
Value:
for((item = (L).first()) ? (e = (item)->elem()) : 0; item !=0; \
(item = (item)->succ()) ? (e = (item)->elem()) : 0)
The iterator forAllListElem assigns to Type e all elements in the list beginning with the first element. 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_LIST<Type>). | |
item | An auxilliary pointer to a list item (ABA_LISTITEM<Type> *). | |
e | The elements in the list are assigned to this variable (Type). |