General Utility Library for C++14  2.11
Classes | Enumerations
gul14/SlidingBuffer.h

Detailed Description

A ring buffer.

Classes

class  gul14::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  gul14::SlidingBufferExposed< ElementT, fixed_capacity, Container >
 A variant of SlidingBuffer that exposes the underlying container through its iterator interface. More...
 

Enumerations

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

Enumeration Type Documentation

◆ ShrinkBehavior

enum gul14::ShrinkBehavior
strong

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 (ShrinkBehavior::keep_front_elements)
  2. Keep the elements with the higher indices (ShrinkBehavior::keep_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