21 #ifndef GNSS_SDR_CIRCULAR_DEQUE_H 22 #define GNSS_SDR_CIRCULAR_DEQUE_H 24 #include <boost/circular_buffer.hpp> 33 unsigned int size(
unsigned int ch);
34 T&
at(
unsigned int ch,
unsigned int pos);
35 const T&
get(
unsigned int ch,
unsigned int pos)
const;
36 T&
front(
unsigned int ch);
37 T&
back(
unsigned int ch);
38 void push_back(
unsigned int ch,
const T& new_data);
40 void clear(
unsigned int ch);
41 void reset(
unsigned int max_size,
unsigned int nchann);
45 std::vector<boost::circular_buffer<T>> d_data;
59 reset(max_size, nchann);
66 return d_data[ch].size();
73 return d_data[ch].back();
80 return d_data[ch].front();
87 return d_data.at(ch).at(pos);
94 return d_data[ch][pos];
109 if (max_size > 0 and nchann > 0)
111 for (
unsigned int i = 0; i < nchann; i++)
113 d_data.push_back(boost::circular_buffer<T>(max_size));
129 d_data[ch].pop_front();
136 d_data[ch].push_back(new_data);
139 #endif // GNSS_SDR_CIRCULAR_DEQUE_H const T & get(unsigned int ch, unsigned int pos) const
Returns a const reference to an element without bound checking.
T & at(unsigned int ch, unsigned int pos)
Returns a reference to an element with bount checking.
unsigned int size(unsigned int ch)
Returns the number of available elements in a channel.
void clear(unsigned int ch)
Removes all the elements of the deque (Sets size to 0). Capacity is not modified. ...
void reset()
Removes all the channels (Sets nchann to 0)
T & back(unsigned int ch)
Returns a reference to the last element in the deque.
void push_back(unsigned int ch, const T &new_data)
Inserts an element at the end of the deque.
T & front(unsigned int ch)
Returns a reference to the first element in the deque.
void pop_front(unsigned int ch)
Removes the first element of the deque.
Gnss_circular_deque()
Default constructor.