The cdc_stack is a struct and functions that provide a stack.
More...
#include <cdcontainers/common.h>
#include <cdcontainers/status.h>
#include <cdcontainers/tables/isequence.h>
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
|
enum cdc_stat | cdc_stack_ctor (const struct cdc_sequence_table *table, struct cdc_stack **s, struct cdc_data_info *info) |
| Constructs an empty stack. More...
|
|
enum cdc_stat | cdc_stack_ctorl (const struct cdc_sequence_table *table, struct cdc_stack **s, struct cdc_data_info *info,...) |
| Constructs a stack, initialized by an arbitrary number of pointers. The last item must be NULL. More...
|
|
enum cdc_stat | cdc_stack_ctorv (const struct cdc_sequence_table *table, struct cdc_stack **s, struct cdc_data_info *info, va_list args) |
| Constructs a stack, initialized by args. The last item must be NULL. More...
|
|
void | cdc_stack_dtor (struct cdc_stack *s) |
| Destroys the stack. More...
|
|
static void * | cdc_stack_top (struct cdc_stack *s) |
| Returns a pointer to the stack's top item. This function assumes that the stack isn't empty. More...
|
|
static bool | cdc_stack_empty (struct cdc_stack *s) |
| Returns true if the stack has size 0; otherwise returns false. More...
|
|
static size_t | cdc_stack_size (struct cdc_stack *s) |
| Returns the number of items in the stack. More...
|
|
static enum cdc_stat | cdc_stack_push (struct cdc_stack *s, void *elem) |
| Adds element elem to the top of the stack. More...
|
|
static void | cdc_stack_pop (struct cdc_stack *s) |
| Removes the top item from the stack. This function assumes that the stack isn't empty. More...
|
|
void | cdc_stack_swap (struct cdc_stack *a, struct cdc_stack *b) |
| Swaps stack a and b. This operation is very fast and never fails. More...
|
|
The cdc_stack is a struct and functions that provide a stack.
- Author
- Maksim Andrianov maksi.nosp@m.mand.nosp@m.riano.nosp@m.v1@y.nosp@m.andex.nosp@m..ru
◆ cdc_stack_ctor()
Constructs an empty stack.
- Parameters
-
- Returns
- CDC_STATUS_OK in a successful case or other value indicating an error
◆ cdc_stack_ctorl()
Constructs a stack, initialized by an arbitrary number of pointers. The last item must be NULL.
- Parameters
-
- Returns
- CDC_STATUS_OK in a successful case or other value indicating an error
◆ cdc_stack_ctorv()
Constructs a stack, initialized by args. The last item must be NULL.
- Parameters
-
- Returns
- CDC_STATUS_OK in a successful case or other value indicating an error
◆ cdc_stack_dtor()
Destroys the stack.
- Parameters
-
◆ cdc_stack_top()
static void* cdc_stack_top |
( |
struct cdc_stack * |
s | ) |
|
|
inlinestatic |
Returns a pointer to the stack's top item. This function assumes that the stack isn't empty.
- Parameters
-
- Returns
- pointer to the stack's top item
◆ cdc_stack_empty()
static bool cdc_stack_empty |
( |
struct cdc_stack * |
s | ) |
|
|
inlinestatic |
Returns true if the stack has size 0; otherwise returns false.
- Parameters
-
- Returns
- true if the list has size 0; otherwise returns false
◆ cdc_stack_size()
static size_t cdc_stack_size |
( |
struct cdc_stack * |
s | ) |
|
|
inlinestatic |
Returns the number of items in the stack.
- Parameters
-
- Returns
- size
◆ cdc_stack_push()
Adds element elem to the top of the stack.
- Parameters
-
- Returns
- CDC_STATUS_OK in a successful case or other value indicating an error
◆ cdc_stack_pop()
static void cdc_stack_pop |
( |
struct cdc_stack * |
s | ) |
|
|
inlinestatic |
Removes the top item from the stack. This function assumes that the stack isn't empty.
- Parameters
-
◆ cdc_stack_swap()
Swaps stack a and b. This operation is very fast and never fails.
- Parameters
-