ucx
UAP Common Extensions
|
Interface for iterator implementations. More...
#include "common.h"
Go to the source code of this file.
Data Structures | |
struct | cx_iterator_base_s |
The base of mutating and non-mutating iterators. More... | |
struct | cx_mut_iterator_s |
Internal iterator struct - use CxMutIterator. More... | |
struct | cx_iterator_s |
Internal iterator struct - use CxIterator. More... | |
Macros | |
#define | cxIteratorValid(iter) (iter).base.valid(&(iter)) |
Checks if the iterator points to valid data. | |
#define | cxIteratorCurrent(iter) (iter).base.current(&iter) |
Returns a pointer to the current element. | |
#define | cxIteratorNext(iter) (iter).base.next(&iter) |
Advances the iterator to the next element. | |
#define | cxIteratorFlagRemoval(iter) (iter).base.flag_removal(&iter) |
Flags the current element for removal. | |
#define | cx_foreach(type, elem, iter) for (type elem; cxIteratorValid(iter) && (elem = (type)cxIteratorCurrent(iter)) != NULL ; cxIteratorNext(iter)) |
Loops over an iterator. | |
Typedefs | |
typedef struct cx_mut_iterator_s | CxMutIterator |
Mutating iterator value type. | |
typedef struct cx_iterator_s | CxIterator |
Iterator value type. | |
Interface for iterator implementations.
#define cx_foreach | ( | type, | |
elem, | |||
iter | |||
) | for (type elem; cxIteratorValid(iter) && (elem = (type)cxIteratorCurrent(iter)) != NULL ; cxIteratorNext(iter)) |
Loops over an iterator.
type | the type of the elements |
elem | the name of the iteration variable |
iter | the iterator |
#define cxIteratorCurrent | ( | iter | ) | (iter).base.current(&iter) |
Returns a pointer to the current element.
The behavior is undefined if this iterator is invalid.
iter | the iterator |
#define cxIteratorFlagRemoval | ( | iter | ) | (iter).base.flag_removal(&iter) |
Flags the current element for removal.
iter | the iterator |
#define cxIteratorNext | ( | iter | ) | (iter).base.next(&iter) |
Advances the iterator to the next element.
iter | the iterator |
#define cxIteratorValid | ( | iter | ) | (iter).base.valid(&(iter)) |
Checks if the iterator points to valid data.
This is especially false for past-the-end iterators.
iter | the iterator |
typedef struct cx_iterator_s CxIterator |
Iterator value type.
An iterator points to a certain element in a (possibly unbounded) chain of elements. Iterators that are based on collections (which have a defined "first" element), are supposed to be "position-aware", which means that they keep track of the current index within the collection.
typedef struct cx_mut_iterator_s CxMutIterator |
Mutating iterator value type.
An iterator points to a certain element in an (possibly unbounded) chain of elements. Iterators that are based on collections (which have a defined "first" element), are supposed to be "position-aware", which means that they keep track of the current index within the collection.