template<typename T, typename Allocator = std::allocator<T>>
CircularBuffer class
High-performance circular buffer with perfect forwarding.
| Template parameters | |
|---|---|
| T | Element type |
| Allocator | Allocator type (default: std::allocator<T>) |
Wraps boost::circular_buffer with additional functionality for game state analysis and pattern recognition.
Public types
- using value_type = T
- using allocator_type = Allocator
- using buffer_type = boost::circular_buffer<T, Allocator>
- using size_type = typename buffer_type::size_type
- using iterator = typename buffer_type::iterator
- using const_iterator = typename buffer_type::const_iterator
Constructors, destructors, conversion operators
-
CircularBuffer(size_
type capacity, const Allocator& alloc = Allocator()) explicit - Construct circular buffer with specified capacity.
Public functions
-
template<typename... Args>void emplace_back(Args && ... args)
- Push element with perfect forwarding.
-
template<typename... Args>void emplace_front(Args && ... args)
- Push element with perfect forwarding at front.
-
auto at(size_
type index) -> T& - Access element at index with bounds checking.
-
auto at(size_
type index) const -> const T& -
auto get_window(size_
type window_size) const -> std::vector<T> - Get sliding window of elements.
-
template<typename Func>void for_each_window(size_
type window_size, Func func) const - Apply function to sliding windows.
-
template<typename Extractor>auto calculate_statistics(Extractor extractor) const -> std::tuple< double, double, double, double > -> auto
- Calculate statistics over the buffer.
-
template<typename Predicate>auto find_patterns(size_
type pattern_size, Predicate predicate) const -> std::vector<size_ type> - Find patterns in the buffer.
- void push_back(const T& value)
- void push_back(T&& value)
- void push_front(const T& value)
- void push_front(T&& value)
- void pop_back()
- void pop_front()
- void clear()
- auto empty() const -> bool
-
auto size() const -> size_
type -
auto capacity() const -> size_
type - auto full() const -> bool
- auto front() -> T&
- auto front() const -> const T&
- auto back() -> T&
- auto back() const -> const T&
- auto begin() -> iterator
-
auto begin() const -> const_
iterator - auto end() -> iterator
-
auto end() const -> const_
iterator
Function documentation
template<typename T, typename Allocator>
liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: CircularBuffer(size_ type capacity,
const Allocator& alloc = Allocator()) explicit
Construct circular buffer with specified capacity.
| Parameters | |
|---|---|
| capacity | Maximum number of elements |
| alloc | Allocator instance |
template<typename T, typename Allocator>
template<typename... Args>
void liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: emplace_back(Args && ... args)
Push element with perfect forwarding.
| Template parameters | |
|---|---|
| Args | Argument types for T's constructor |
| Parameters | |
| args | Arguments to forward to T's constructor |
template<typename T, typename Allocator>
template<typename... Args>
void liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: emplace_front(Args && ... args)
Push element with perfect forwarding at front.
| Template parameters | |
|---|---|
| Args | Argument types for T's constructor |
| Parameters | |
| args | Arguments to forward to T's constructor |
template<typename T, typename Allocator>
std::vector<T> liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: get_window(size_ type window_size) const
Get sliding window of elements.
| Parameters | |
|---|---|
| window_size | Size of the window |
| Returns | Vector containing the last window_size elements |
template<typename T, typename Allocator>
template<typename Func>
void liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: for_each_window(size_ type window_size,
Func func) const
Apply function to sliding windows.
| Template parameters | |
|---|---|
| Func | Function type |
| Parameters | |
| window_size | Size of each window |
| func | Function to apply to each window |
template<typename T, typename Allocator>
template<typename Extractor>
auto liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: calculate_statistics(Extractor extractor) const -> std::tuple< double, double, double, double >
Calculate statistics over the buffer.
| Template parameters | |
|---|---|
| Extractor | Function to extract numeric value from T |
| Parameters | |
| extractor | Function to extract value for statistics |
| Returns | Tuple of (mean, std_dev, min, max) |
template<typename T, typename Allocator>
template<typename Predicate>
std::vector<size_ type> liarsdice:: data_structures:: CircularBuffer<T, Allocator>:: find_patterns(size_ type pattern_size,
Predicate predicate) const
Find patterns in the buffer.
| Template parameters | |
|---|---|
| Predicate | Predicate type |
| Parameters | |
| pattern_size | Size of pattern to search for |
| predicate | Function to check if elements form a pattern |
| Returns | Vector of starting indices where patterns are found |