All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Macros | Functions
as_queue.h File Reference
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
+ Include dependency graph for as_queue.h:

Go to the source code of this file.

Data Structures

struct  as_queue
 

Macros

#define as_queue_inita(__q, __item_size, __capacity)
 

Functions

as_queueas_queue_create (uint32_t item_size, uint32_t capacity)
 
void as_queue_destroy (as_queue *queue)
 
static bool as_queue_empty (as_queue *queue)
 
bool as_queue_init (as_queue *queue, uint32_t item_size, uint32_t capacity)
 
bool as_queue_pop (as_queue *queue, void *ptr)
 
bool as_queue_push (as_queue *queue, const void *ptr)
 
bool as_queue_push_head (as_queue *queue, const void *ptr)
 
bool as_queue_push_limit (as_queue *queue, const void *ptr)
 
static uint32_t as_queue_size (as_queue *queue)
 

Macro Definition Documentation

#define as_queue_inita (   __q,
  __item_size,
  __capacity 
)
Value:
(__q)->data = alloca((__capacity) * (__item_size));\
(__q)->capacity = __capacity;\
(__q)->head = (__q)->tail = 0;\
(__q)->item_size = __item_size;\
(__q)->flags = 0;
uint8_t data[]
Definition: as_proto.h:830

Initialize a stack allocated as_queue, with item storage on the stack. as_queue_inita() will transfer stack memory to the heap if a resize is required.

Definition at line 76 of file as_queue.h.

Function Documentation

as_queue* as_queue_create ( uint32_t  item_size,
uint32_t  capacity 
)

Create a heap allocated as_queue, with item storage on the heap.

void as_queue_destroy ( as_queue queue)

Release queue memory.

static bool as_queue_empty ( as_queue queue)
inlinestatic

Is queue empty?

Definition at line 118 of file as_queue.h.

References as_queue::head, and as_queue::tail.

bool as_queue_init ( as_queue queue,
uint32_t  item_size,
uint32_t  capacity 
)

Initialize a stack allocated as_queue, with item storage on the heap.

bool as_queue_pop ( as_queue queue,
void *  ptr 
)

Pop from the head of the queue.

bool as_queue_push ( as_queue queue,
const void *  ptr 
)

Push to the tail of the queue.

bool as_queue_push_head ( as_queue queue,
const void *  ptr 
)

Push to the front of the queue.

bool as_queue_push_limit ( as_queue queue,
const void *  ptr 
)

Push element on the queue only if size < capacity.

static uint32_t as_queue_size ( as_queue queue)
inlinestatic

Get the number of elements currently in the queue.

Definition at line 109 of file as_queue.h.

References as_queue::head, and as_queue::tail.