18#ifndef GNSS_SDR_CIRCULAR_DEQUE_H
19#define GNSS_SDR_CIRCULAR_DEQUE_H
21#include <boost/circular_buffer.hpp>
36 unsigned int size(
unsigned int ch)
const;
37 T&
at(
unsigned int ch,
unsigned int pos);
38 const T&
get(
unsigned int ch,
unsigned int pos)
const;
44 void reset(
unsigned int max_size,
unsigned int nchann);
48 std::vector<boost::circular_buffer<T>> d_data;
62 reset(max_size, nchann);
69 return d_data[ch].size();
76 return d_data[ch].back();
83 return d_data[ch].front();
90 return d_data.at(ch).at(pos);
97 return d_data[ch][pos];
112 if (max_size > 0 and nchann > 0)
114 for (
unsigned int i = 0; i < nchann; i++)
116 d_data.push_back(boost::circular_buffer<T>(max_size));
132 d_data[ch].pop_front();
139 d_data[ch].push_back(new_data);
void reset()
Removes all the channels (Sets nchann to 0).
void push_back(unsigned int ch, const T &new_data)
Inserts an element at the end of the deque.
T & back(unsigned int ch)
Returns a reference to the last element in the deque.
unsigned int size(unsigned int ch) const
Returns the number of available elements in a channel.
void pop_front(unsigned int ch)
Removes the first element of the deque.
void reset(unsigned int max_size, unsigned int nchann)
Removes all the elements in all the channels. Re-sets the number of channels and their capacity.
T & at(unsigned int ch, unsigned int pos)
Returns a reference to an element with bound checking.
const T & get(unsigned int ch, unsigned int pos) const
Returns a const reference to an element without bound checking.
T & front(unsigned int ch)
Returns a reference to the first element in the deque.
void clear(unsigned int ch)
Removes all the elements of the deque (Sets size to 0). Capacity is not modified.
Gnss_circular_deque()
Default constructor.