|
event_detector 1.0.0
|
Ring-buffer-like container for keeping only values within a fixed range of a secondary index parameter. More...
#include <DifferenceBasedBuffer.hpp>
Public Member Functions | |
| DifferenceBasedBuffer (const D &diff=D(0, 0)) | |
| Constructs a new DifferenceBasedBuffer object. | |
| void | setDifference (const D &diff) |
| Sets new difference. Will affect subsequent calls to update(). | |
| void | push_back (const T &val, const C &stamp=C()) |
| Adds new element to the end. | |
| void | push_front (const T &val, const C &stamp=C()) |
| Adds new element to the front. | |
| void | insert (typename StampedDeque< T, C >::const_iterator position, const T &val, const C &stamp=C()) |
| Adds new element at position. | |
| T & | operator[] (const int n) |
| Accesses specified element. | |
| const T & | operator[] (const int n) const |
| Accesses specified element. | |
| T & | at (const int n) |
| Accesses specified element. | |
| const T & | at (const int n) const |
| Accesses specified element. | |
| std::pair< C, T > & | get (const int n) |
| Accesses specified element including stamp. | |
| const std::pair< C, T > & | get (const int n) const |
| Accesses specified element including stamp. | |
| T & | front () |
| Accesses first element. | |
| const T & | front () const |
| Accesses first element. | |
| T & | back () |
| Accesses last element. | |
| const T & | back () const |
| Accesses last element. | |
Protected Member Functions | |
| void | update (const C &stamp) |
| Removes all elements with stamps outside of (stamp - diff_, stamp]. | |
Protected Attributes | |
| D | diff_ |
| Difference value. | |
Ring-buffer-like container for keeping only values within a fixed range of a secondary index parameter.
A DifferenceBasedBuffer is a special type of deque similar to a fixed length circular buffer. Instead of having a fixed length, the DifferenceBasedBuffer only keeps those values, whose secondary stamp value is within a fixed range of the most recently inserted value's stamp. As an example, a DifferenceBasedBuffer can thus be used for keeping all values with a stamp within the last 5 minutes by using timestamps as the secondary stamp argument upon insertion.
| T | type of values to store |
| C | type of secondary index parameter |
| D | type of secondary index parameter range (C-C) |
Definition at line 57 of file DifferenceBasedBuffer.hpp.
| DifferenceBasedBuffer< T, C, D >::DifferenceBasedBuffer | ( | const D & | diff = D(0, 0) | ) |
Constructs a new DifferenceBasedBuffer object.
| diff | fixed range from most recent stamp within which values are kept in the buffer |
| T & DifferenceBasedBuffer< T, C, D >::at | ( | const int | n | ) |
Accesses specified element.
| n | index of requested element |
| const T & DifferenceBasedBuffer< T, C, D >::at | ( | const int | n | ) | const |
Accesses specified element.
| n | index of requested element |
| T & DifferenceBasedBuffer< T, C, D >::back | ( | ) |
Accesses last element.
| const T & DifferenceBasedBuffer< T, C, D >::back | ( | ) | const |
Accesses last element.
| T & DifferenceBasedBuffer< T, C, D >::front | ( | ) |
Accesses first element.
| const T & DifferenceBasedBuffer< T, C, D >::front | ( | ) | const |
Accesses first element.
| std::pair< C, T > & DifferenceBasedBuffer< T, C, D >::get | ( | const int | n | ) |
Accesses specified element including stamp.
| n | index of requested element |
| const std::pair< C, T > & DifferenceBasedBuffer< T, C, D >::get | ( | const int | n | ) | const |
Accesses specified element including stamp.
| n | index of requested element |
| void DifferenceBasedBuffer< T, C, D >::insert | ( | typename StampedDeque< T, C >::const_iterator | position, |
| const T & | val, | ||
| const C & | stamp = C() |
||
| ) |
Adds new element at position.
All elements with stamps outside (stamp - diff_, stamp] will be removed.
| position | iterator before which the element will be inserted |
| val | new value to add |
| stamp | stamp of new element |
| T & DifferenceBasedBuffer< T, C, D >::operator[] | ( | const int | n | ) |
Accesses specified element.
| n | index of requested element |
| const T & DifferenceBasedBuffer< T, C, D >::operator[] | ( | const int | n | ) | const |
Accesses specified element.
| n | index of requested element |
| void DifferenceBasedBuffer< T, C, D >::push_back | ( | const T & | val, |
| const C & | stamp = C() |
||
| ) |
Adds new element to the end.
All elements with stamps outside (stamp - diff_, stamp] will be removed.
| val | new value to add |
| stamp | stamp of new element |
| void DifferenceBasedBuffer< T, C, D >::push_front | ( | const T & | val, |
| const C & | stamp = C() |
||
| ) |
Adds new element to the front.
All elements with stamps outside (stamp - diff_, stamp] will be removed.
| val | new value to add |
| stamp | stamp of new element |
|
protected |
Removes all elements with stamps outside of (stamp - diff_, stamp].
| stamp | upper bound of range within which to keep values |
|
protected |
Difference value.
Used for removing elements when the difference between their stamp value the newest stamp value is greater than this difference value.
Definition at line 199 of file DifferenceBasedBuffer.hpp.