C Container Collection (CCC)
Loading...
Searching...
No Matches
impl_flat_double_ended_queue.h
1
16#ifndef CCC_IMPL_FLAT_DOUBLE_ENDED_QUEUE_H
17#define CCC_IMPL_FLAT_DOUBLE_ENDED_QUEUE_H
18
20#include <stddef.h>
23#include "../buffer.h"
24
25/* NOLINTBEGIN(readability-identifier-naming) */
26
33struct ccc_fdeq
34{
36 ccc_buffer buf;
38 size_t front;
39};
40
41/*======================= Private Interface ============================*/
43void *ccc_impl_fdeq_alloc_front(struct ccc_fdeq *);
45void *ccc_impl_fdeq_alloc_back(struct ccc_fdeq *);
46
47/*======================= Macro Implementations ==========================*/
48
50#define ccc_impl_fdeq_init(impl_mem_ptr, impl_alloc_fn, impl_aux_data, \
51 impl_capacity, optional_size...) \
52 { \
53 .buf = ccc_buf_init(impl_mem_ptr, impl_alloc_fn, impl_aux_data, \
54 impl_capacity, optional_size), \
55 .front = 0, \
56 }
57
59#define ccc_impl_fdeq_emplace_back(fdeq_ptr, value...) \
60 (__extension__({ \
61 __auto_type impl_fdeq_ptr = (fdeq_ptr); \
62 void *const impl_fdeq_emplace_ret = NULL; \
63 if (impl_fdeq_ptr) \
64 { \
65 void *const impl_fdeq_emplace_ret \
66 = ccc_impl_fdeq_alloc_back(impl_fdeq_ptr); \
67 if (impl_fdeq_emplace_ret) \
68 { \
69 *((typeof(value) *)impl_fdeq_emplace_ret) = value; \
70 } \
71 } \
72 impl_fdeq_emplace_ret; \
73 }))
74
76#define ccc_impl_fdeq_emplace_front(fdeq_ptr, value...) \
77 (__extension__({ \
78 __auto_type impl_fdeq_ptr = (fdeq_ptr); \
79 void *const impl_fdeq_emplace_ret = NULL; \
80 if (impl_fdeq_ptr) \
81 { \
82 void *const impl_fdeq_emplace_ret \
83 = ccc_impl_fdeq_alloc_front(impl_fdeq_ptr); \
84 if (impl_fdeq_emplace_ret) \
85 { \
86 *((typeof(value) *)impl_fdeq_emplace_ret) = value; \
87 } \
88 } \
89 impl_fdeq_emplace_ret; \
90 }))
91
92/* NOLINTEND(readability-identifier-naming) */
93
94#endif /* CCC_IMPL_FLAT_DOUBLE_ENDED_QUEUE_H */
struct ccc_buffer ccc_buffer
A contiguous block of storage for elements of the same type.
Definition: buffer.h:65