Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_ring_buffer.H File Reference

Bounded circular buffer (Aleph::RingBuffer) for FIFO streaming. More...

#include <cstddef>
#include <iterator>
#include <memory>
#include <type_traits>
#include <utility>
#include <ah-errors.H>
Include dependency graph for tpl_ring_buffer.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::RingBuffer< T >
 Fixed-capacity circular FIFO buffer over contiguous storage. More...
 
class  Aleph::RingBuffer< T >::basic_iterator< IsConst >
 Random-access iterator over the logical window. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Detailed Description

Bounded circular buffer (Aleph::RingBuffer) for FIFO streaming.

RingBuffer<T> is a fixed-capacity FIFO over one contiguous allocation: put appends at the tail, get extracts from the head, both O(1), and the storage never reallocates after construction. The optional put_overwrite policy silently evicts the oldest element when full, which turns the buffer into a sliding window over a stream — the classic use in producer/consumer stages, telemetry, audio and logging.

How it differs from the existing circular queues:

  • ArrayQueue grows dynamically (capacity is a power of two) — it is a general-purpose queue, not a bounded window.
  • FixedQueue is fixed-size but performs no checking at all and requires default-constructible elements.
  • RingBuffer has an exact user-chosen capacity, checked operations (Aleph error macros), an explicit overwrite policy, indexed access to the window, and constructs elements in place — T needs no default constructor and move-only types are supported.
See also
tpl_arrayQueue.H Dynamic (ArrayQueue) and unchecked fixed (FixedQueue) circular queues.
Author
Leandro Rabindranath Leon

Definition in file tpl_ring_buffer.H.