#include <stdint.h>Macros | |
| #define | DEFINE_STACK_TYPE(typename, value_type, max_size) |
| A new stack type definition. More... | |
| #define | DEFINE_STACK(typename, stack) |
| A predefined stack definition with no elements. More... | |
| #define | STACK_PUSH(stack, value) |
| Inserts a new element at the top of the stack. The content of this new element is initialized to a copy of val. More... | |
| #define | STACK_POP(stack) |
| Removes the element on top of the stack. More... | |
| #define | STACK_TOP(stack) |
| #define | STACK_EMPTY(stack) |
| #define | STACK_SIZE(stack) |
| #define | STACK_MAX_SIZE(stack) |
| #define | STACK_CLEAR(stack) |
Stacks are a type of container, specifically designed to operate in a LIFO context (last-in first-out), where elements are inserted and extracted only from one end of the container.
Example:
Output:
| #define DEFINE_STACK | ( | typename, | |
| stack | |||
| ) |
A predefined stack definition with no elements.
| typename | The stack type |
| stack | The stack |
| #define DEFINE_STACK_TYPE | ( | typename, | |
| value_type, | |||
| max_size | |||
| ) |
A new stack type definition.
| typename | Name of the new stack type |
| value_type | Type of element. |
| max_size | Maximal size of the stack. It defines the fixed-size of the static defined array. |
| #define STACK_CLEAR | ( | stack | ) |
Remove all elements from the stack.
| stack | The stack |
| #define STACK_EMPTY | ( | stack | ) |
Returns true if the stack is empty.
| stack | The stack |
| #define STACK_MAX_SIZE | ( | stack | ) |
Returns the size() of the largest possible stack.
| stack | The stack |
| #define STACK_POP | ( | stack | ) |
Removes the element on top of the stack.
| stack | The stack |
| #define STACK_PUSH | ( | stack, | |
| value | |||
| ) |
Inserts a new element at the top of the stack. The content of this new element is initialized to a copy of val.
| stack | The stack |
| value | Data to be added. |
| #define STACK_SIZE | ( | stack | ) |
Returns the number of elements in the stack.
| stack | The stack |
| #define STACK_TOP | ( | stack | ) |
Returns a read/write pointer to the data at the top element of the stack. stack.
| stack | The stack |