15 #ifndef ECL_CONTAINERS_PUSH_AND_POP_FIXED_HPP_ 16 #define ECL_CONTAINERS_PUSH_AND_POP_FIXED_HPP_ 27 #include "../array.hpp" 41 namespace formatters {
43 template <
typename Type,
size_t N>
class PushAndPopFormatter;
75 template<
typename Type, std::
size_t Size=DynamicStorage>
101 Type & operator[] (
int idx)
103 return data[ ((follower+idx)%size_fifo) ];
106 const Type & operator[] (
int idx)
const 108 return data[ ((follower+idx)%size_fifo) ];
115 for(
int i=0; i<size_fifo; i++ )
117 data[i] = otherOne.
data[i];
129 data[ leader++ ] = datum;
131 if( leader == follower )
134 follower %= size_fifo;
142 Type value = data[follower++];
143 follower %= size_fifo;
149 for(
unsigned int i=0; i<size_fifo; i++ ) data[i] = d;
164 if( leader > follower )
return leader - follower;
165 else if( leader < follower )
return size_fifo-follower+leader;
177 std::cout <<
"[Size|Leader|Follower]: " << size_fifo <<
"|" << leader <<
"|" << follower << std::endl;
PushAndPop(const Type &d)
formatters::PushAndPopFormatter< Type, Size > Formatter
Formatter for this class.
Embedded control libraries.
Surpport push and pack operation.
#define ecl_assert_throw(expression, exception)
void push_back(const Type &datum)
Pushes an element onto the back of the container.
unsigned int size() const
ecl::Array< Type, Size+1 > data