General circular buffer class. More...
#include <itpp/base/circular_buffer.h>
Public Member Functions | |
Circular_Buffer () | |
Default constructor. More... | |
Circular_Buffer (int n) | |
Create a Circular_Buffer of size n . More... | |
Circular_Buffer (const Circular_Buffer< T > &s) | |
Create a copy of s . More... | |
virtual | ~Circular_Buffer () |
Default destructor. More... | |
void | put (const T &in) |
Write the element in to the buffer. More... | |
void | put (const Vec< T > &in) |
Write the vector of elements in to the circular buffer. More... | |
void | put (const Array< T > &in) |
Write the vector of elements in to the circular buffer. More... | |
void | get (T &out) |
Get the oldest element in the circular buffer. More... | |
T | get () |
Get the oldest element in the circular buffer. More... | |
void | get (Vec< T > &out, const int N=-1) |
Get the N oldest element in the circular buffer. N=-1 returns all elements in the buffer. More... | |
void | get (Array< T > &out, const int N=-1) |
Get the N oldest element in the circular buffer. N=-1 returns all elements in the buffer. More... | |
void | peek (T &out) const |
Peek at the oldest element in the circular buffer, without removing it. More... | |
T | peek () const |
Peek at the oldest element in the circular buffer, without removing it. More... | |
void | peek (const int index, T &out) const |
Peek at the element with index index in the circular buffer, without removing it. More... | |
void | peek (Vec< T > &out, const int N=-1) const |
Peek at the N first elements of the circular buffer, without removing them. N=-1 peeks all elements in the buffer. More... | |
void | peek (const ivec &index, Vec< T > &out) const |
Peek at the elements with index index in the circular buffer, without removing them. More... | |
void | peek (Array< T > &out, const int N=-1) const |
Peek at the N first elements of the circular buffer, without removing them. N=-1 peeks all elements in the buffer. More... | |
void | peek (const ivec &index, Array< T > &out) const |
Peek at the elements with index index in the circular buffer, without removing them. More... | |
void | peek_reverse (T &out) const |
Peek at the latest element in the circular buffer, without removing it. More... | |
T | peek_reverse () const |
Peek at the latest element in the circular buffer, without removing it. More... | |
void | peek_reverse (Vec< T > &out, const int N=-1) const |
Peek at the N latest elements of the circular buffer in reverse order, without removing them. N=-1 returns all elements in the buffer. More... | |
void | peek_reverse (Array< T > &out, const int N=-1) const |
Peek at the N latest elements of the circular buffer in reverse order, without removing them. N=-1 returns all elements in the buffer. More... | |
void | clear () |
Empty the circular buffer. More... | |
void | operator= (const Circular_Buffer< T > &s) |
Assignment operator. More... | |
int | size () const |
Returns the maximum number of data elements the circular buffer can store. More... | |
int | nrof_elements () const |
Returns the number of data elements currently stored in the circular buffer. More... | |
void | set_size (int n, bool copy=false) |
Resizing a Circular_Buffer<T>. More... | |
General circular buffer class.
This class is a general circular buffer class for arbitrary types.
For rarely used types you will need to instantiate the class by
The following example shows how to define a Circular_Buffer of doubles:
Definition at line 92 of file circular_buffer.h.
itpp::Circular_Buffer< T >::Circular_Buffer |
Default constructor.
Definition at line 192 of file circular_buffer.h.
itpp::Circular_Buffer< T >::Circular_Buffer | ( | int | n | ) |
Create a Circular_Buffer of size n
.
Definition at line 202 of file circular_buffer.h.
itpp::Circular_Buffer< T >::Circular_Buffer | ( | const Circular_Buffer< T > & | s | ) |
Create a copy of s
.
Definition at line 211 of file circular_buffer.h.
|
virtual |
Default destructor.
Definition at line 224 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::put | ( | const T & | in | ) |
Write the element in to the buffer.
Definition at line 463 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::put | ( | const Vec< T > & | in | ) |
Write the vector of elements in to the circular buffer.
Definition at line 483 of file circular_buffer.h.
References itpp::Vec< Num_T >::size().
void itpp::Circular_Buffer< T >::put | ( | const Array< T > & | in | ) |
Write the vector of elements in to the circular buffer.
Definition at line 505 of file circular_buffer.h.
References itpp::Array< T >::size().
void itpp::Circular_Buffer< T >::get | ( | T & | out | ) |
Get the oldest element in the circular buffer.
Definition at line 230 of file circular_buffer.h.
References it_assert_debug.
T itpp::Circular_Buffer< T >::get |
Get the oldest element in the circular buffer.
Definition at line 241 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::get | ( | Vec< T > & | out, |
const int | N = -1 |
||
) |
Get the N oldest element in the circular buffer. N=-1
returns all elements in the buffer.
Definition at line 250 of file circular_buffer.h.
References it_assert_debug, and itpp::Vec< Num_T >::set_size().
void itpp::Circular_Buffer< T >::get | ( | Array< T > & | out, |
const int | N = -1 |
||
) |
Get the N oldest element in the circular buffer. N=-1
returns all elements in the buffer.
Definition at line 273 of file circular_buffer.h.
References it_assert_debug, and itpp::Array< T >::set_size().
void itpp::Circular_Buffer< T >::peek | ( | T & | out | ) | const |
Peek at the oldest element in the circular buffer, without removing it.
Definition at line 296 of file circular_buffer.h.
References it_assert_debug.
T itpp::Circular_Buffer< T >::peek |
Peek at the oldest element in the circular buffer, without removing it.
Definition at line 303 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::peek | ( | const int | index, |
T & | out | ||
) | const |
Peek at the element with index index in the circular buffer, without removing it.
Definition at line 312 of file circular_buffer.h.
References it_assert_debug.
void itpp::Circular_Buffer< T >::peek | ( | Vec< T > & | out, |
const int | N = -1 |
||
) | const |
Peek at the N first elements of the circular buffer, without removing them. N=-1
peeks all elements in the buffer.
Definition at line 319 of file circular_buffer.h.
References it_assert_debug, and itpp::Vec< Num_T >::set_size().
void itpp::Circular_Buffer< T >::peek | ( | const ivec & | index, |
Vec< T > & | out | ||
) | const |
Peek at the elements with index index in the circular buffer, without removing them.
Definition at line 341 of file circular_buffer.h.
References it_assert_debug, and itpp::Vec< Num_T >::set_size().
void itpp::Circular_Buffer< T >::peek | ( | Array< T > & | out, |
const int | N = -1 |
||
) | const |
Peek at the N first elements of the circular buffer, without removing them. N=-1
peeks all elements in the buffer.
Definition at line 352 of file circular_buffer.h.
References it_assert_debug, and itpp::Array< T >::set_size().
void itpp::Circular_Buffer< T >::peek | ( | const ivec & | index, |
Array< T > & | out | ||
) | const |
Peek at the elements with index index in the circular buffer, without removing them.
Definition at line 374 of file circular_buffer.h.
References it_assert_debug, and itpp::Array< T >::set_size().
void itpp::Circular_Buffer< T >::peek_reverse | ( | T & | out | ) | const |
Peek at the latest element in the circular buffer, without removing it.
Definition at line 385 of file circular_buffer.h.
References it_assert_debug.
T itpp::Circular_Buffer< T >::peek_reverse |
Peek at the latest element in the circular buffer, without removing it.
Definition at line 400 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::peek_reverse | ( | Vec< T > & | out, |
const int | N = -1 |
||
) | const |
Peek at the N latest elements of the circular buffer in reverse order, without removing them. N=-1
returns all elements in the buffer.
Definition at line 409 of file circular_buffer.h.
References it_assert_debug, and itpp::Vec< Num_T >::set_size().
void itpp::Circular_Buffer< T >::peek_reverse | ( | Array< T > & | out, |
const int | N = -1 |
||
) | const |
Peek at the N latest elements of the circular buffer in reverse order, without removing them. N=-1
returns all elements in the buffer.
Definition at line 436 of file circular_buffer.h.
References it_assert_debug, and itpp::Array< T >::set_size().
void itpp::Circular_Buffer< T >::clear |
Empty the circular buffer.
Definition at line 526 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::operator= | ( | const Circular_Buffer< T > & | s | ) |
Assignment operator.
Definition at line 563 of file circular_buffer.h.
|
inline |
Returns the maximum number of data elements the circular buffer can store.
Definition at line 168 of file circular_buffer.h.
|
inline |
Returns the number of data elements currently stored in the circular buffer.
Definition at line 171 of file circular_buffer.h.
void itpp::Circular_Buffer< T >::set_size | ( | int | n, |
bool | copy = false |
||
) |
Resizing a Circular_Buffer<T>.
Definition at line 574 of file circular_buffer.h.
Generated on Tue Aug 17 2021 10:59:15 for IT++ by Doxygen 1.9.4