Declaration of the SortStrategy structure and the SortStrategy_Initialize() function as used in the Strategy Pattern. More...
#include <stdbool.h>

Go to the source code of this file.
Classes | |
| struct | EntryInformation |
| Represents an individual with a Name, Age, and Height. More... | |
| struct | SortStrategy |
| Represents the strategy to use for sorting EntryInformation objects. More... | |
Macros | |
| #define | __STRATEGY_SORTSTRATEGY_H__ |
Typedefs | |
| typedef bool(* | CompareFunction) (const EntryInformation *, const EntryInformation *) |
| Alias for a function that compares two EntryInformation objects to determine if the left comes before the right. | |
Enumerations | |
| enum | SortOptions { Sort_ByName = 0 , Sort_ByAge , Sort_ByHeight } |
| Represents the difference sorting strategies supported. More... | |
Functions | |
| void | SortStrategy_Initialize (SortStrategy *strategy, SortOptions sortOption, bool reversedSort) |
| Initialize a SortStrategy object with the desired strategy. | |
Declaration of the SortStrategy structure and the SortStrategy_Initialize() function as used in the Strategy Pattern.
Definition in file Strategy_SortStrategy.h.
| #define __STRATEGY_SORTSTRATEGY_H__ |
Definition at line 8 of file Strategy_SortStrategy.h.
| typedef bool(* CompareFunction) (const EntryInformation *, const EntryInformation *) |
Alias for a function that compares two EntryInformation objects to determine if the left comes before the right.
Definition at line 67 of file Strategy_SortStrategy.h.
| enum SortOptions |
Represents the difference sorting strategies supported.
These values are used as an index into the sortingStrategies array defined in the Strategy_SortStrategy.c file.
| Enumerator | |
|---|---|
| Sort_ByName | Sort alphabetically name in ascending order. |
| Sort_ByAge | Sort numerically by age in ascending order. |
| Sort_ByHeight | Sort numerically by height in ascending order. |
Definition at line 44 of file Strategy_SortStrategy.h.
| void SortStrategy_Initialize | ( | SortStrategy * | strategy, |
| SortOptions | sortOption, | ||
| bool | reversedSort | ||
| ) |
Initialize a SortStrategy object with the desired strategy.
| strategy | The SortStrategy object to initialize. |
| sortOption | A value from the SortOptions enumeration specifying the sorting strategy to use. |
| reversedSort | True if to reverse the sense of the compare function. |
Definition at line 112 of file Strategy_SortStrategy.c.
References SortStrategyItem::compareFunction, SortStrategy::compareFunction, SortStrategyItem::name, SortStrategy::name, SortStrategy::reversedSort, and sortingStrategies.
Referenced by Strategy_Exercise().