15 #ifndef ECL_CONTAINERS_PUSH_AND_POP_DYNAMIC_HPP_ 16 #define ECL_CONTAINERS_PUSH_AND_POP_DYNAMIC_HPP_ 36 namespace formatters {
38 template <
typename Type,
size_t N>
class PushAndPopFormatter;
70 template<
typename Type>
93 : size_fifo(length+1), leader(0), follower(0)
96 data.resize( size_fifo );
99 PushAndPop(
const unsigned int length,
const Type & d ) :
105 data.resize( size_fifo );
152 const_iterator
end()
const {
162 return reverse_iterator(end());
171 return const_reverse_iterator(end());
180 return reverse_iterator(begin());
188 const_reverse_iterator
rend()
const {
189 return const_reverse_iterator(begin());
198 Type & operator[] (
int idx)
200 return data[ ((follower+idx)%size_fifo) ];
203 const Type & operator[] (
int idx)
const 205 return data[ ((follower+idx)%size_fifo) ];
212 for(
int i=0; i<size_fifo; i++ )
214 data[i] = otherOne.
data[i];
226 data[ leader++ ] = datum;
228 if( leader == follower )
231 follower %= size_fifo;
239 Type value = data[follower++];
240 follower %= size_fifo;
246 for(
unsigned int i=0; i<size_fifo; i++ ) data[i] = d;
251 size_fifo = length+1;
253 data.resize( size_fifo );
270 if( leader > follower )
return leader - follower;
271 else if( leader < follower )
return size_fifo-follower+leader;
std::reverse_iterator< const_iterator > const_reverse_iterator
Embedded control libraries.
std::reverse_iterator< iterator > reverse_iterator
Surpport push and pack operation.
unsigned int size() const
std::ptrdiff_t difference_type
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
PushAndPop()
Default constructor.
#define ecl_assert_throw(expression, exception)
const_iterator begin() const
const Type * const_iterator
const_iterator end() const
A simple fifo implementation.
formatters::PushAndPopFormatter< Type, DynamicStorage > Formatter
Formatter for this class.
const_reverse_iterator rend() const
const Type & const_reference
PushAndPop(const unsigned int length)
void resize(unsigned int length)
void push_back(const Type &datum)
Pushes an element onto the back of the container.
PushAndPop(const unsigned int length, const Type &d)
ecl::Array< Type, Size+1 > data
unsigned int asize()
The size allocated in memory for the fifo.