LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
stack_api.h File Reference

Fixed-capacity LIFO stack built on the Array API. More...

#include "juno/ds/array_api.h"
#include "juno/macros.h"
#include "juno/status.h"
#include "juno/module.h"
Include dependency graph for stack_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JUNO_DS_STACK_API_TAG
 

Typedefs

typedef struct JUNO_DS_STACK_ROOT_TAG JUNO_DS_STACK_ROOT_T
 The stack root module.
 
typedef struct JUNO_DS_STACK_API_TAG JUNO_DS_STACK_API_T
 

Functions

struct JUNO_DS_STACK_ROOT_TAG JUNO_MODULE_ROOT (JUNO_DS_STACK_API_T, JUNO_DS_ARRAY_ROOT_T *ptStackArray;size_t zLength;)
 Stack root instance and state.
 
static JUNO_STATUS_T JunoDs_StackVerify (const JUNO_DS_STACK_ROOT_T *ptStack)
 
JUNO_STATUS_T JunoDs_StackInit (JUNO_DS_STACK_ROOT_T *ptStack, JUNO_DS_ARRAY_ROOT_T *ptStackArray, JUNO_FAILURE_HANDLER_T pfcnFailureHdlr, JUNO_USER_DATA_T *pvFailureUserData)
 Initialize a stack over a backing array with a given capacity.
 
JUNO_STATUS_T JunoDs_StackPush (JUNO_DS_STACK_ROOT_T *ptStack, JUNO_POINTER_T tItem)
 Push an item onto the top of the stack (O(1)).
 
JUNO_STATUS_T JunoDs_StackPop (JUNO_DS_STACK_ROOT_T *ptStack, JUNO_POINTER_T tReturn)
 Pop the top item into tReturn (O(1)).
 
JUNO_RESULT_POINTER_T JunoDs_StackPeek (JUNO_DS_STACK_ROOT_T *ptStack)
 Peek at the top item without removing it (O(1)).
 

Detailed Description

Fixed-capacity LIFO stack built on the Array API.

This API has been generated by LibJuno: https://www.robinonsay.com/libjuno/

Typedef Documentation

◆ JUNO_DS_STACK_API_T

◆ JUNO_DS_STACK_ROOT_T

typedef struct JUNO_DS_STACK_ROOT_TAG JUNO_DS_STACK_ROOT_T

The stack root module.

Function Documentation

◆ JunoDs_StackInit()

JUNO_STATUS_T JunoDs_StackInit ( JUNO_DS_STACK_ROOT_T ptStack,
JUNO_DS_ARRAY_ROOT_T ptStackArray,
JUNO_FAILURE_HANDLER_T  pfcnFailureHdlr,
JUNO_USER_DATA_T pvFailureUserData 
)

Initialize a stack over a backing array with a given capacity.

Parameters
ptStackStack to initialize (output).
ptStackArrayBacking array used for storage; defines capacity and element size.
pfcnFailureHdlrFailure callback for assertions in this module.
pvFailureUserDataOpaque user data for the failure handler.
Returns
JUNO_STATUS_SUCCESS on success; error if array verification fails.

Initialize a stack over a backing array with a given capacity.

◆ JunoDs_StackPeek()

JUNO_RESULT_POINTER_T JunoDs_StackPeek ( JUNO_DS_STACK_ROOT_T ptStack)

Peek at the top item without removing it (O(1)).

Peek at the next item in the queue

Returns
the index of the next item in the queue

◆ JunoDs_StackPop()

JUNO_STATUS_T JunoDs_StackPop ( JUNO_DS_STACK_ROOT_T ptStack,
JUNO_POINTER_T  tReturn 
)

Pop the top item into tReturn (O(1)).

Dequeue an item from the buffer

Returns
The index to dequeue the item from

◆ JunoDs_StackPush()

JUNO_STATUS_T JunoDs_StackPush ( JUNO_DS_STACK_ROOT_T ptStack,
JUNO_POINTER_T  tItem 
)

Push an item onto the top of the stack (O(1)).

Enqueue an item into the buffer

Returns
The index to place the enqueued item

◆ JunoDs_StackVerify()

static JUNO_STATUS_T JunoDs_StackVerify ( const JUNO_DS_STACK_ROOT_T ptStack)
inlinestatic