General Utility Library for C++17 25.4.1
Classes | Enumerations
gul17/SlidingBuffer.h

Detailed Description

A ring buffer.

Classes

class  gul17::SlidingBuffer< ElementT, fixed_capacity, Container >
 A circular data buffer of (semi-)fixed capacity to which elements can be added at the front or at the back. More...
 
class  gul17::SlidingBufferExposed< ElementT, fixed_capacity, Container >
 A variant of SlidingBuffer that exposes the underlying container through its iterator interface. More...
 

Enumerations

enum class  gul17::ShrinkBehavior { keep_front_elements , keep_back_elements }
 Determine how a SlidingBuffer handles decreases of its size. More...
 

Enumeration Type Documentation

◆ ShrinkBehavior

Determine how a SlidingBuffer handles decreases of its size.

When the buffer's capacity decreases below the actual size some elements have to be dropped. The user can choose between two strategies:

  1. Keep the elements with the lower indices (`ShrinkBehaviorkeep_front_elements`)
  2. Keep the elements with the higher indices (`ShrinkBehaviorkeep_back_elements`)

Usually the more recent data shall be preserved, while older data can be dropped.

The behavior is utilized by SlidingBuffer::resize(), SlidingBuffer::reserve(), SlidingBufferExposed::resize(), and SlidingBufferExposed::reserve().

Since
GUL version 1.3