Design Pattern Examples
Overview of object-oriented design patterns
Iterator_Iterators.h
Go to the documentation of this file.
1
7
8#pragma once
9#ifndef __ITERATOR_ITERATORS_H__
10#define __ITERATOR_ITERATORS_H__
11
12#include <stdbool.h>
13#include <stddef.h>
14
18typedef struct
19{
20 const char* key;
21 const char* value;
22} ItemPair;
23
27typedef struct
28{
35
39 size_t iterator;
41
45typedef struct
46{
52 const char* key;
53
57 size_t iterator;
59
60
64typedef struct
65{
71 const char* value;
72
76 size_t iterator;
78
79
80//-----------------------------------------------------------------------------
81//-----------------------------------------------------------------------------
82
88void Iterator_GetItems(ItemIterator* iterator);
89
95void Iterator_GetKeys(KeyIterator* iterator);
96
102void Iterator_GetValues(ValueIterator* iterator);
103
110bool Iterator_NextItem(ItemIterator* iterator);
111
118bool Iterator_NextKey(KeyIterator* iterator);
119
126bool Iterator_NextValue(ValueIterator* iterator);
127
128#endif // __ITERATOR_ITERATORS_H__
void Iterator_GetItems(ItemIterator *iterator)
Retrieve an iterator over the whole items in the internal data structure.
void Iterator_GetValues(ValueIterator *iterator)
Retrieve an iterator over the values in the internal data structure.
void Iterator_GetKeys(KeyIterator *iterator)
Retrieve an iterator over the keys in the internal data structure.
bool Iterator_NextValue(ValueIterator *iterator)
Retrieve the next value (const char*) from the iterator.
bool Iterator_NextKey(KeyIterator *iterator)
Retrieve the next key (const char*) from the iterator.
bool Iterator_NextItem(ItemIterator *iterator)
Retrieve the next whole item (ItemPair) from the iterator.
Represents an iterator that retrieves whole items.
ItemPair item
The key/value pair pointed to by this iterator. item.key and item.value are NULL if Iterator_NextItem...
size_t iterator
The (opaque) iterator value tracking progress through the data.
Represents a key/value pair where the key and value are strings.
const char * value
The value part of the item.
const char * key
The key part of the item.
Represents an iterator that retrieves the key of each item.
size_t iterator
The (opaque) iterator value tracking progress through the data.
const char * key
The key pointed to by this iterator. key is NULL if Iterator_NextKey() has not yet been called or the...
Represents an iterator that retrieves the value of each item.
const char * value
The value pointed to by this iterator. value is NULL if Iterator_NextValue() has not yet been called ...
size_t iterator
The (opaque) iterator value tracking progress through the data.