O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
queue.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
14/* ************************************************************************** */
15
16#include "o2s/queue.h"
17
20{
21 deque_free(self);
22}
23
25bool queue_push(queue_t* self, const void* element)
26{
27 return deque_push_back(self, element);
28}
29
31bool queue_push_n(queue_t* self, const void* elements, size_t count)
32{
33 return deque_push_back_n(self, elements, count);
34}
35
37bool queue_pop(queue_t* self, void* destination)
38{
39 return deque_pop_front(self, destination);
40}
41
43bool queue_pop_n(queue_t* self, void* destination, size_t count)
44{
45 return deque_pop_front_n(self, destination, count);
46}
47
49size_t queue_room(const queue_t* self)
50{
51 return deque_room(self);
52}
53
55size_t queue_count(const queue_t* self)
56{
57 return deque_count(self);
58}
59
61size_t queue_capacity(const queue_t* self)
62{
63 return deque_capacity(self);
64}
65
67void* queue_first(const queue_t* self)
68{
69 return deque_first(self);
70}
71
73void* queue_get(const queue_t* self, size_t index)
74{
75 return deque_get(self, index);
76}
77
79bool queue_pop_into_array(queue_t* self, struct array* destination, size_t count)
80{
81 return deque_pop_front_into_array(self, destination, count);
82}
void deque_free(deque_t *self)
Frees properly the deque.
size_t deque_capacity(const deque_t *self)
The maximum number of elements that can be stored.
Definition getters.c:28
void * deque_first(const deque_t *self)
The current first element in the queue.
Definition getters.c:37
size_t deque_count(const deque_t *self)
The number of elements currently held in the queue.
Definition getters.c:22
void * deque_get(const deque_t *self, size_t index)
The element of the element at an arbitrary index.
Definition getters.c:72
bool deque_pop_front(deque_t *self, void *destination)
Pops the front-most element of the queue, copying it to destination.
Definition pop.c:29
bool deque_pop_front_n(deque_t *self, void *destination, size_t count)
Pops the count first elements of the queue.
Definition pop.c:45
size_t deque_room(const deque_t *self)
The remaining number of elements that can be added.
Definition internals.c:27
bool deque_pop_front_into_array(deque_t *self, struct array *destination, size_t count)
Move the count first elements at the back of destination.
Definition into_array.c:24
bool deque_push_back(deque_t *self, const void *element)
Inserts an element to the back of the queue.
Definition push.c:59
bool deque_push_back_n(deque_t *self, const void *elements, size_t count)
Inserts count elements to the back of the queue.
Definition push.c:68
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
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
Realtime FIFO buffer.
deque_t queue_t
A queue is First In First Out.
Definition queue.h:21