Implementation of the iterator functions, Iterator_GetItems(), Iterator_GetKeys(), Iterator_GetValues(), Iterator_NextItem(), Iterator_NextKey(), and Iterator_NextValue(), as used in the Iterator Pattern. More...
Go to the source code of this file.
Functions | |
void | Iterator_GetItems (ItemIterator *iterator) |
Retrieve an iterator over the whole items in the internal data structure. | |
void | Iterator_GetKeys (KeyIterator *iterator) |
Retrieve an iterator over the keys in the internal data structure. | |
void | Iterator_GetValues (ValueIterator *iterator) |
Retrieve an iterator over the values in the internal data structure. | |
bool | Iterator_NextItem (ItemIterator *iterator) |
Retrieve the next whole item (ItemPair) from the iterator. | |
bool | Iterator_NextKey (KeyIterator *iterator) |
Retrieve the next key (const char*) from the iterator. | |
bool | Iterator_NextValue (ValueIterator *iterator) |
Retrieve the next value (const char*) from the iterator. | |
Variables | |
static const char * | _keys [] = { "One" , "Two" , "Three" } |
A list of keys as example data. The number of keys must match the number of values in the _values list. | |
static const char * | _values [] = { "Value 1", "Value 2", "Value 3" } |
A list of values as example data. The number of values must match the number of keys in the _keys list. | |
Implementation of the iterator functions, Iterator_GetItems(), Iterator_GetKeys(), Iterator_GetValues(), Iterator_NextItem(), Iterator_NextKey(), and Iterator_NextValue(), as used in the Iterator Pattern.
Definition in file Iterator_Iterators.c.
void Iterator_GetItems | ( | ItemIterator * | iterator | ) |
Retrieve an iterator over the whole items in the internal data structure.
iterator | Pointer to an ItemIterator object to populate with the iterator. Call Iterator_NextItem() to start using the iterator. |
Definition at line 32 of file Iterator_Iterators.c.
References ItemIterator::item, ItemIterator::iterator, ItemPair::key, and ItemPair::value.
Referenced by Iterator_Exercise().
void Iterator_GetKeys | ( | KeyIterator * | iterator | ) |
Retrieve an iterator over the keys in the internal data structure.
iterator | Pointer to an KeyIterator object to populate with the iterator. Call Iterator_NextKey() to start using the iterator. |
Definition at line 45 of file Iterator_Iterators.c.
References KeyIterator::iterator, and KeyIterator::key.
Referenced by Iterator_Exercise().
void Iterator_GetValues | ( | ValueIterator * | iterator | ) |
Retrieve an iterator over the values in the internal data structure.
iterator | Pointer to an ValueIterator object to populate with the iterator. Call Iterator_NextValue() to start using the iterator. |
Definition at line 57 of file Iterator_Iterators.c.
References ValueIterator::iterator, and ValueIterator::value.
Referenced by Iterator_Exercise().
bool Iterator_NextItem | ( | ItemIterator * | iterator | ) |
Retrieve the next whole item (ItemPair) from the iterator.
iterator | The KeyIterator used to get the next item. |
Definition at line 69 of file Iterator_Iterators.c.
References _keys, _values, ItemIterator::item, ItemIterator::iterator, ItemPair::key, and ItemPair::value.
Referenced by Iterator_Exercise().
bool Iterator_NextKey | ( | KeyIterator * | iterator | ) |
Retrieve the next key (const char*) from the iterator.
iterator | The ItemIterator used to get the next key. |
Definition at line 99 of file Iterator_Iterators.c.
References _keys, KeyIterator::iterator, and KeyIterator::key.
Referenced by Iterator_Exercise().
bool Iterator_NextValue | ( | ValueIterator * | iterator | ) |
Retrieve the next value (const char*) from the iterator.
iterator | The ValueIterator used to get the next value. |
Definition at line 127 of file Iterator_Iterators.c.
References _values, ValueIterator::iterator, and ValueIterator::value.
Referenced by Iterator_Exercise().
|
static |
A list of keys as example data. The number of keys must match the number of values in the _values list.
Definition at line 17 of file Iterator_Iterators.c.
Referenced by IteratorContainer_Class::GetItems(), IteratorContainer_Class::GetKeys(), Iterator_NextItem(), and Iterator_NextKey().
|
static |
A list of values as example data. The number of values must match the number of keys in the _keys list.
Definition at line 23 of file Iterator_Iterators.c.
Referenced by IteratorContainer_Class::GetItems(), IteratorContainer_Class::GetValues(), Iterator_NextItem(), and Iterator_NextValue().