Design Pattern Examples
Overview of object-oriented design patterns
c/Iterator_Exercise.h File Reference

Declaration of the Iterator_Exercise() function as used in the Iterator Pattern. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __ITERATOR_EXERCISE_H__
 

Functions

void Iterator_Exercise (void)
 Example of using the Iterator Pattern.
 

Detailed Description

Declaration of the Iterator_Exercise() function as used in the Iterator Pattern.

Definition in file c/Iterator_Exercise.h.

Macro Definition Documentation

◆ __ITERATOR_EXERCISE_H__

#define __ITERATOR_EXERCISE_H__

Definition at line 9 of file c/Iterator_Exercise.h.

Function Documentation

◆ Iterator_Exercise()

void Iterator_Exercise ( void  )

Example of using the Iterator Pattern.

A custom container is instantiated (it already contains hard-coded data to iterate over). The custom container can then deliver three iterators, each providing a different aspect of the hard-coded data.

The output shows the output from each iterator.

Definition at line 32 of file Iterator_Exercise.c.

References ItemIterator::item, Iterator_GetItems(), Iterator_GetKeys(), Iterator_GetValues(), Iterator_NextItem(), Iterator_NextKey(), Iterator_NextValue(), ItemPair::key, KeyIterator::key, ItemPair::value, and ValueIterator::value.