ATLAS Offline Software
|
A very simple ring buffer. More...
#include <Ring.h>
Public Member Functions | |
void | reset (size_t size) |
Clear the buffer and set its size. More... | |
void | push (const T &x) |
Add a new item to the buffer. More... | |
std::vector< T > | getKeysDedup () const |
Return a copy of keys in the buffer. More... | |
Private Attributes | |
std::vector< T > | m_data |
size_t | m_pos = 0 |
A very simple ring buffer.
The payload class T must support comparison and default construction. Default-constructed T's are used to indicate unfilled slots in the buffer.
Start by calling reset
to set the size of the buffer. Then push
will add new elements to the ring.
The only operation to retrieve values at this point is getKeysDedup
. More could be added if needed.
std::vector<T> CxxUtils::Ring< T >::getKeysDedup | ( | ) | const |
Return a copy of keys in the buffer.
Immediately adjacent duplicates and unfilled entries will be removed, so the result may be smaller than the size of the buffer.
void CxxUtils::Ring< T >::push | ( | const T & | x | ) |
Add a new item to the buffer.
x | Item to add. |
void CxxUtils::Ring< T >::reset | ( | size_t | size | ) |
Clear the buffer and set its size.
size | New size of the buffer. |
|
private |
|
private |