libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblRingBuffer Struct Reference

#include <gimbal_ring_buffer.h>

Data Fields

struct { 
 
   GblContext *   pCtx 
 
   uint8_t *   pData 
 
   size_t   size 
 
   size_t   capacity 
 
   size_t   frontPos 
 
   uint16_t   elementSize 
 
private_ 
 

Detailed Description

Contiguous, array-based circular/ring buffer with queue semantics.

GblRingBuffer is a generic container of fixed capacity, to which elements may be enqueued or dequeued without requiring any shuffling around in memory. Rather than resizing when the capacity is reached, any new values simply overrwrite the oldest values. Insertions and removals are performed semantically like a queue: pushing to the back and popping from the front; however, since the container is implemented as a contiguous array, it is also randomly accessible.

Operation Time Complexity
iteration O(N)
insertion (back) O(1)
removal (front) O(1)
access (front or back) O(1)
random access (middle) O(1)

These properties make this structure well-suited for FIFO or queue style structures of fixed sizes as well as for representing stream buffers in memory, where a producer is pushing new entries while a consumer pops them.

See also
GblDeque, GblArrayList

Definition at line 52 of file gimbal_ring_buffer.h.

Field Documentation

◆ pCtx

GblContext* GblRingBuffer::pCtx

Definition at line 54 of file gimbal_ring_buffer.h.

◆ pData

uint8_t* GblRingBuffer::pData

Definition at line 55 of file gimbal_ring_buffer.h.

◆ size

size_t GblRingBuffer::size

Definition at line 56 of file gimbal_ring_buffer.h.

◆ capacity

size_t GblRingBuffer::capacity

Definition at line 57 of file gimbal_ring_buffer.h.

◆ frontPos

size_t GblRingBuffer::frontPos

Definition at line 58 of file gimbal_ring_buffer.h.

◆ elementSize

uint16_t GblRingBuffer::elementSize

Definition at line 59 of file gimbal_ring_buffer.h.


The documentation for this struct was generated from the following file: