Declaration of the StackEntry structure and the supporting functions that represents a simple stack. More...
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | StackEntry |
Represents an entry on a simple stack that wraps an "item" represented by an opaque pointer. More... | |
Macros | |
#define | __STACK_H__ |
Typedefs | |
typedef struct StackEntry | StackEntry |
Represents an entry on a simple stack that wraps an "item" represented by an opaque pointer. | |
Functions | |
void | Stack_Push (StackEntry **stack, void *item) |
Push the given entry onto the given stack. | |
void * | Stack_Pop (StackEntry **stack) |
Pop the last entry from the given stack, returning the item. | |
bool | Stack_IsEmpty (StackEntry **stack) |
Determines if the given stack is empty. | |
Declaration of the StackEntry structure and the supporting functions that represents a simple stack.
Definition in file stack.h.
typedef struct StackEntry StackEntry |
Represents an entry on a simple stack that wraps an "item" represented by an opaque pointer.
This structure is allocated on the heap and then linked into the stack. The item is what is being pushed onto the stack, the StackEntry structure provides the necessary link to the next older StackEntry structure containing the next older item.
bool Stack_IsEmpty | ( | StackEntry ** | stack | ) |
Determines if the given stack is empty.
stack | A pointer to a pointer to a StackEntry object representing the top of the stack. Points to a NULL if the stack is empty. This pointer to a pointer cannot be NULL. |
Definition at line 82 of file stack.c.
Referenced by Command_Undo().
void * Stack_Pop | ( | StackEntry ** | stack | ) |
Pop the last entry from the given stack, returning the item.
stack | A pointer to a pointer to a StackEntry object representing the top of the stack. Points to a NULL if the stack is empty. This pointer to a pointer cannot be NULL. |
Definition at line 63 of file stack.c.
References StackEntry::item, StackEntry::next, and StackEntry_Destroy().
Referenced by Command_Undo(), and Memento_Undo().
void Stack_Push | ( | StackEntry ** | stack, |
void * | item | ||
) |
Push the given entry onto the given stack.
stack | A pointer to a pointer to a StackEntry object representing the top of the stack. Points to a NULL if the stack is empty. This pointer to a pointer cannot be NULL. |
item | The item to store on the stack. |
Definition at line 40 of file stack.c.
References StackEntry::next, and StackEntry_Create().
Referenced by Command_Save_And_Execute(), Command_Undo(), and Memento_SaveForUndo().