Data Structures | |
| struct | Cmaid_Iter |
| The Iterator Class structure Do not manipulate the attributes directly. More... | |
Modules | |
| The Iterator Interface | |
Typedefs | |
| typedef struct Cmaid_Iter | Cmaid_Iter |
| Type definition of the Iterator Class. | |
Functions | |
| CMAID_INLINE void | cmaid_iter_start (Cmaid_Iter *it) |
| Move the iterator to the start. | |
| CMAID_INLINE void * | cmaid_iter_iter_goto (Cmaid_Iter *it, const Cmaid_Iter *to_it) |
| move the given iterator to the second iterator's place | |
| CMAID_INLINE void * | cmaid_iter_index_goto (Cmaid_Iter *it, int index) |
| move the iterator to the give position | |
| CMAID_INLINE int | cmaid_iter_index_get (Cmaid_Iter *it) |
| Retrieve the current index. | |
| CMAID_INLINE Cmaid_Container * | cmaid_iter_container_get (Cmaid_Iter *it) |
| Retrieve the parent container of the iterator. | |
| CMAID_INLINE void * | cmaid_iter_current (Cmaid_Iter *it) |
| Returns the data pointer of the current node. | |
| CMAID_INLINE void * | cmaid_iter_next (Cmaid_Iter *it) |
| Walks to the next node and returns its data pointer. | |
| CMAID_INLINE void * | cmaid_iter_previous (Cmaid_Iter *it) |
| Walks to the previous node and returns its data pointer. | |
| CMAID_INLINE void | cmaid_iter_remove (Cmaid_Iter *it) |
| Remove the current node. | |
The iterator class forms the heart of Cmaid and makes Cmaid different to other abstract data type libraries. Like in any other data type library you can iterate with them over a container and remove objects from the container, but unlike in other implementations the iterator points still to a valid node if you remove an object, even if you did not removed it with the iterator itself.
Example:
extern Cmaid_Container *c; Cmaid_Iter it; cmaid_container_iter_attach(c, &it); // work with the iterator cmaid_container_iter_detach(c, &it);
Example:
cmaid_iter_start(&it); // "it" is pointing to the node before the first node cmaid_iter_next(&it); // "it" points now to the first node, if the container // is not empty while ((item = cmaid_iter_next(&it)) printf("%s\n", item); // prints every string in the container except // the first one // "it" is now pointing to the node before the first node again
| CMAID_INLINE Cmaid_Container* cmaid_iter_container_get | ( | Cmaid_Iter * | it | ) |
Retrieve the parent container of the iterator.
| it | The iterator to work with |
| CMAID_INLINE void* cmaid_iter_current | ( | Cmaid_Iter * | it | ) |
Returns the data pointer of the current node.
| it | The iterator to retrieve the current data |
NULL. | CMAID_INLINE int cmaid_iter_index_get | ( | Cmaid_Iter * | it | ) |
Retrieve the current index.
| it | the iterator to get the index |
| CMAID_INLINE void* cmaid_iter_index_goto | ( | Cmaid_Iter * | it, | |
| int | index | |||
| ) |
move the iterator to the give position
| it | the iterator to move | |
| index | the new position of the iterator |
| CMAID_INLINE void* cmaid_iter_iter_goto | ( | Cmaid_Iter * | it, | |
| const Cmaid_Iter * | to_it | |||
| ) |
move the given iterator to the second iterator's place
| it | the iter to move | |
| to_it | the new position for the iterator This function moves the given iterator to the same position like the given iterator has. This will fail if the iterators are for different containers. |
| CMAID_INLINE void* cmaid_iter_next | ( | Cmaid_Iter * | it | ) |
Walks to the next node and returns its data pointer.
| it | The iterator to retrieve the next data |
NULL. | CMAID_INLINE void* cmaid_iter_previous | ( | Cmaid_Iter * | it | ) |
Walks to the previous node and returns its data pointer.
| it | The iterator to retrieve the previous data |
NULL. | CMAID_INLINE void cmaid_iter_remove | ( | Cmaid_Iter * | it | ) |
Remove the current node.
| it | The iterator to removoe the current node |
| CMAID_INLINE void cmaid_iter_start | ( | Cmaid_Iter * | it | ) |
Move the iterator to the start.
| it | the iterator to move |
1.5.8