|
| FiFo (const unsigned int length=0) |
| Initialises the fifo, but does not fill it. More...
|
|
| FiFo (const unsigned int length, const T &value) |
| Initialise and fill the fifo. More...
|
|
void | fill (const T &value) |
| One-shot fill method. More...
|
|
unsigned int | get_idx () |
| Index of the oldest element in the fifo. More...
|
|
T & | operator[] (int idx) |
| Returns the indexed value offset from the oldest data. More...
|
|
const T & | operator[] (int idx) const |
| Const version of the [] accessor. More...
|
|
void | push_back (const T &datum) |
| Push back onto the fifo. More...
|
|
void | resize (unsigned int length) |
| Resize the fifo storage. More...
|
|
virtual | ~FiFo () |
| Default destructor. More...
|
|
template<typename T>
class ecl::FiFo< T >
Really simple fifo implementation.
For control programs, fifo is typically used for data storage, moving average and some applications. It uses ecl::Array internally for storage (all exception handling is thus handled by ecl::Array).
Usage:
During the construction of fifo, typically length of buffer may be important.
FiFo<double> fifo(4);
fifo.push_back( data_incoming );
But initial value for whole buffer can be important to you.
Especially if you want to use fifo for moving average,
you should wait
for N (length of buffer) incoming of
data.
But if you use below code, you can use fifo immediately
@code
FiFo<double> fifo(4, initial_value);
fifo.push_back( next_data );
...
Data access
[0] always return oldest data set from the fifo and [N-1] returns always new data from the fifo once your buffer is full.
FiFo<double> fifo(4);
fifo.push_back(1.0);
fifo.push_back(2.0);
fifo.push_back(3.0);
fifo.push_back(4.0);
std::cout << fifo[0] << std::endl;
std::cout << fifo[3] << std::endl;
- See also
- ecl::Array.
Definition at line 82 of file fifo.hpp.