![]() |
GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Circular buffer indexing and iterators. More...
#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | gp_cbuffer |
| A circular buffer indexes. More... | |
| struct | gp_cbuffer_iter |
| An interator for loops over the circular buffer. More... | |
Macros | |
| #define | GP_CBUFFER_FOREACH(self, iter) |
| Loops over all elements in the circular buffer. | |
| #define | GP_CBUFFER_FORRANGE(self, iter, skip, count) |
| Loops over a range of elements in the circular buffer. | |
| #define | GP_CBUFFER_FOREACH_REV(self, iter) |
| Loops backwards over all elements in the circular buffer. | |
Typedefs | |
| typedef struct gp_cbuffer | gp_cbuffer |
| A circular buffer indexes. | |
| typedef struct gp_cbuffer_iter | gp_cbuffer_iter |
| An interator for loops over the circular buffer. | |
Functions | |
| static void | gp_cbuffer_init (gp_cbuffer *self, size_t size) |
| Initializes circular buffer. | |
| static size_t | gp_cbuffer_append (gp_cbuffer *self) |
| Appends into circular buffer. | |
| static size_t | gp_cbuffer_next (gp_cbuffer *self, size_t idx) |
| Returns next position in the circular buffer. | |
| static size_t | gp_cbuffer_prev (gp_cbuffer *self, size_t idx) |
| Returns previous position in the circular buffer. | |
| static size_t | gp_cbuffer_used (gp_cbuffer *self) |
| Returns number of used positions in the circular buffer. | |
| static size_t | gp_cbuffer_first (gp_cbuffer *self) |
| Returns index to the first element in buffer. | |
| static size_t | gp_cbuffer_last (gp_cbuffer *self) |
| Returns index to the last element in buffer. | |
Circular buffer indexing and iterators.
Definition in file gp_cbuffer.h.
| #define GP_CBUFFER_FOREACH | ( | self, | |
| iter ) |
Loops over all elements in the circular buffer.
| self | A circular buffer. |
| iter | A circular buffer iterator variable. |
Definition at line 151 of file gp_cbuffer.h.
| #define GP_CBUFFER_FOREACH_REV | ( | self, | |
| iter ) |
Loops backwards over all elements in the circular buffer.
| self | A circular buffer. |
| iter | A circular buffer iterator variable. |
Definition at line 176 of file gp_cbuffer.h.
| #define GP_CBUFFER_FORRANGE | ( | self, | |
| iter, | |||
| skip, | |||
| count ) |
Loops over a range of elements in the circular buffer.
| self | A circular buffer. |
| iter | A circular buffer iterator variable. |
| skip | How many element should we skip at the start. |
| count | How many element should we iterater over. |
Definition at line 164 of file gp_cbuffer.h.
|
inlinestatic |
Appends into circular buffer.
Only index into the buffer array is returned, any old data has to be freed by the user of this API.
| self | A circular buffer. |
Definition at line 50 of file gp_cbuffer.h.
References gp_cbuffer::last, gp_cbuffer::size, and gp_cbuffer::used.
|
inlinestatic |
Returns index to the first element in buffer.
Returns invalid data for empty buffer, make sure buffer is not empty with gp_buffer_used() before using this function.
| self | A circular buffer. |
Definition at line 109 of file gp_cbuffer.h.
References gp_cbuffer::last, gp_cbuffer::size, and gp_cbuffer::used.
|
inlinestatic |
Initializes circular buffer.
| self | A circular buffer to be initialized. |
| size | Size of the buffer. |
Definition at line 34 of file gp_cbuffer.h.
References gp_cbuffer::last, gp_cbuffer::size, and gp_cbuffer::used.
|
inlinestatic |
Returns index to the last element in buffer.
Returns invalid data for empty buffer, make sure buffer is not empty with gp_buffer_used() before using this function.
| self | A circular buffer. |
Definition at line 130 of file gp_cbuffer.h.
References gp_cbuffer_prev(), and gp_cbuffer::last.
|
inlinestatic |
Returns next position in the circular buffer.
| self | A circular buffer. |
| idx | A current position in the buffer. |
Definition at line 69 of file gp_cbuffer.h.
References gp_cbuffer::size.
|
inlinestatic |
Returns previous position in the circular buffer.
| self | A circular buffer. |
| idx | A current position in the buffer. |
Definition at line 81 of file gp_cbuffer.h.
References gp_cbuffer::size.
Referenced by gp_cbuffer_last().
|
inlinestatic |
Returns number of used positions in the circular buffer.
| self | A circular buffer. |
Definition at line 95 of file gp_cbuffer.h.
References gp_cbuffer::used.