O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
queue.h
Go to the documentation of this file.
1#pragma once
2
3/* ************************************************************************** */
4/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
5/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
6/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
7/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
8/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
9/* */
16/* ************************************************************************** */
17
18#include "o2s/deque.h"
19
22
23#define Queue Deque
24#define QueueAllocate DequeAllocate
25
26void queue_free(queue_t* self);
27
30bool queue_push(queue_t* self, const void* element);
31bool queue_push_n(queue_t* self, const void* elements, size_t count);
32
33bool queue_pop(queue_t* self, void* destination);
34bool queue_pop_n(queue_t* self, void* destination, size_t count);
35
36bool queue_pop_into_array(queue_t* self, struct array* destination, size_t count);
38
41void* queue_first(const queue_t* self);
42void* queue_get(const queue_t* self, size_t index);
44
47size_t queue_room(const queue_t* self);
48size_t queue_count(const queue_t* self);
49size_t queue_capacity(const queue_t* self);
Realtime double-ended queues.
void * queue_get(const queue_t *self, size_t index)
Access an arbitrary queue element.
Definition queue.c:73
bool queue_pop(queue_t *self, void *destination)
Pop the first element of the queue.
Definition queue.c:37
size_t queue_capacity(const queue_t *self)
Number of elements that can be stored in the queue.
Definition queue.c:61
bool queue_pop_n(queue_t *self, void *destination, size_t count)
Pop the first count elements of the queue.
Definition queue.c:43
bool queue_push(queue_t *self, const void *element)
Add a single element to the queue.
Definition queue.c:25
deque_t queue_t
A queue is First In First Out.
Definition queue.h:21
bool queue_push_n(queue_t *self, const void *elements, size_t count)
Add count elements to the queue.
Definition queue.c:31
size_t queue_count(const queue_t *self)
Number of elements currently in the queue.
Definition queue.c:55
size_t queue_room(const queue_t *self)
Number of elements that can be added.
Definition queue.c:49
bool queue_pop_into_array(queue_t *self, struct array *destination, size_t count)
Move the count first elements at the back of destination.
Definition queue.c:79
void queue_free(queue_t *self)
Release the allocated memory.
Definition queue.c:19
void * queue_first(const queue_t *self)
Next element to be popped.
Definition queue.c:67
Double-ended queue.
Definition deque.h:27