Implementation of the SortStrategy structure and the SortStrategy_Initialize() function, along with the individual strategies, as used in the Strategy Pattern. More...

Go to the source code of this file.
Classes | |
| struct | SortStrategyItem |
| Represents a sorting strategy. More... | |
Functions | |
| static bool | _Compare_Name (const EntryInformation *leftEntry, const EntryInformation *rightEntry) |
| Compare the name fields of two EntryInformation objects to determine if the two entries need to be swapped. | |
| static bool | _Compare_Age (const EntryInformation *leftEntry, const EntryInformation *rightEntry) |
| Compare the age fields of two EntryInformation objects to determine if the two entries need to be swapped. | |
| static bool | _Compare_Height (const EntryInformation *leftEntry, const EntryInformation *rightEntry) |
| Compare the height fields of two EntryInformation objects to determine if the two entries need to be swapped. | |
| void | SortStrategy_Initialize (SortStrategy *strategy, SortOptions sortOption, bool reversedSort) |
| Initialize a SortStrategy object with the desired strategy. | |
Variables | |
| static SortStrategyItem | sortingStrategies [] |
| List of sorting strategies as indexed by a value from the SortOptions enumeration. Provides the name of the sorting strategy and the compare function to use. | |
Implementation of the SortStrategy structure and the SortStrategy_Initialize() function, along with the individual strategies, as used in the Strategy Pattern.
Definition in file Strategy_SortStrategy.c.
|
static |
Compare the age fields of two EntryInformation objects to determine if the two entries need to be swapped.
| leftEntry | The left EntryInformation object to compare. |
| rightEntry | The right EntryInformation object to compare. |
Definition at line 43 of file Strategy_SortStrategy.c.
References EntryInformation::Age.
|
static |
Compare the height fields of two EntryInformation objects to determine if the two entries need to be swapped.
| leftEntry | The left EntryInformation object to compare. |
| rightEntry | The right EntryInformation object to compare. |
Definition at line 65 of file Strategy_SortStrategy.c.
References EntryInformation::Height.
|
static |
Compare the name fields of two EntryInformation objects to determine if the two entries need to be swapped.
| leftEntry | The left EntryInformation object to compare. |
| rightEntry | The right EntryInformation object to compare. |
Definition at line 21 of file Strategy_SortStrategy.c.
References EntryInformation::Name.
| 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().
|
static |
List of sorting strategies as indexed by a value from the SortOptions enumeration. Provides the name of the sorting strategy and the compare function to use.
Definition at line 95 of file Strategy_SortStrategy.c.
Referenced by SortStrategy_Initialize().