The LIFO stack.
More...
Go to the source code of this file.
|
typedef struct _StackData | StackData |
| StackData is the data type for the container private information. More...
|
|
The LIFO stack.
Definition in file stack.h.
StackData is the data type for the container private information.
Definition at line 11 of file stack.h.
int32_t StackInit |
( |
Stack ** |
ppObj | ) |
|
The constructor for Stack.
- Parameters
-
ppObj | The double pointer to the to be constructed stack |
- Return values
-
SUCC | |
ERR_NOMEM | Insufficient memory for stack construction |
void StackDeinit |
( |
Stack ** |
ppObj | ) |
|
The destructor for Stack.
If the custom resource clean method is set, it also runs the clean method for all the items.
- Parameters
-
ppObj | The double pointer to the to be destructed stack |
int32_t StackPush |
( |
Stack * |
self, |
|
|
Item |
item |
|
) |
| |
Insert an item to the top of the stack.
This function inserts an item to the top of the stack with the corresponding stack size extension.
- Parameters
-
self | The pointer to Stack structure |
item | The designated item |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_NOMEM | Insufficient memory for stack extension |
int32_t StackPop |
( |
Stack * |
self | ) |
|
Delete item from top of the stack.
This function deletes item from the top of the stack. If the custom resource clean method is set, it also runs the clean method for the deleted item.
- Parameters
-
self | The pointer to Stack structure |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_IDX | Empty stack |
int32_t StackTop |
( |
Stack * |
self, |
|
|
Item * |
pItem |
|
) |
| |
Retrieve item from top of the stack.
This function retrieves item from the top of the stack. If the stack is not empty, the item is returned by the second parameter. Otherwise, the error code is returned and the second parameter is updated with NULL.
- Parameters
-
self | The pointer to Stack structure |
pItem | The pointer to the returned item |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_IDX | Empty stack |
ERR_GET | Invalid parameter to store returned item |
int32_t StackSize |
( |
Stack * |
self | ) |
|
Return the number of stored items.
- Parameters
-
self | The pointer to Stack structure |
- Returns
- The number of items
- Return values
-
ERR_NOINIT | Uninitialized container |
int32_t StackSetDestroy |
( |
Stack * |
self, |
|
|
void(*)(Item) |
pFunc |
|
) |
| |
Set the custom item resource clean method.
- Parameters
-
self | The pointer to Stack structure |
pFunc | The function pointer to the custom method |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |