Integer Stack Utility Functions
This is a simple stack structure with supporting push, pop, and peek functions. More...
Classes | |
struct | _OSRTIntStack |
This is the main stack structure. More... | |
Defines | |
#define | OSRTISTK_DEFAULT_CAPACITY 100 |
This is the default capacity that is used if zero is passed as the capacity argument to rtxIntStackInit. | |
#define | rtxIntStackIsEmpty(stack) (OSBOOL)((stack).index == 0) |
This macro tests if the stack is empty. | |
Functions | |
EXTERNRT int | rtxIntStackInit (OSCTXT *pctxt, OSRTIntStack *pstack, size_t capacity) |
This function initializes a stack structure. | |
EXTERNRT int | rtxIntStackPush (OSRTIntStack *pstack, OSINT32 value) |
This function pushes an item onto the stack. | |
EXTERNRT int | rtxIntStackPeek (OSRTIntStack *pstack, OSINT32 *pvalue) |
This functions returns the data item on the top of the stack. | |
EXTERNRT int | rtxIntStackPop (OSRTIntStack *pstack, OSINT32 *pvalue) |
This functions pops the data item on the top of the stack. |
Detailed Description
This is a simple stack structure with supporting push, pop, and peek functions.
Define Documentation
#define rtxIntStackIsEmpty | ( | stack | ) | (OSBOOL)((stack).index == 0) |
This macro tests if the stack is empty.
- Parameters:
-
stack Stack structure variable to be tested.
Definition at line 122 of file rtxIntStack.h.
Function Documentation
EXTERNRT int rtxIntStackInit | ( | OSCTXT * | pctxt, | |
OSRTIntStack * | pstack, | |||
size_t | capacity | |||
) |
This function initializes a stack structure.
It allocates the initial amount of memory required to store data and sets all working variables to their initil state.
- Parameters:
-
pctxt A pointer to the context with which the stack is associated. pstack A pointer to a stack structure to be initialized. capacity Initial capacity of the stack. This is the number of integer values that can be stored before the stack is expanded. Each expansion doubles the initial capacity value.
- Returns:
- Completion status of operation:
- 0 (0) = success,
- negative return value is error.
EXTERNRT int rtxIntStackPeek | ( | OSRTIntStack * | pstack, | |
OSINT32 * | pvalue | |||
) |
This functions returns the data item on the top of the stack.
- Parameters:
-
pstack A pointer to the stack structure. pvalue A pointer to a variable to store the integer value of the item at the top of the stack.
- Returns:
- Status of peek operation:
- 0 (0) = success,
- RTERR_ENDOFBUF if stack is empty
EXTERNRT int rtxIntStackPop | ( | OSRTIntStack * | pstack, | |
OSINT32 * | pvalue | |||
) |
This functions pops the data item on the top of the stack.
- Parameters:
-
pstack A pointer to the stack structure. pvalue A pointer to a variable to store the integer value of the item at the top of the stack.
- Returns:
- Status of pop operation:
- 0 (0) = success,
- RTERR_ENDOFBUF if stack is empty
EXTERNRT int rtxIntStackPush | ( | OSRTIntStack * | pstack, | |
OSINT32 | value | |||
) |
This function pushes an item onto the stack.
- Parameters:
-
pstack A pointer to the stack structure. value A pointer to the data item to be pushed on the stack.
- Returns:
- Completion status of operation:
- 0 (0) = success,
- negative return value is error.