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>
79 typedef formatters::PushAndPopFormatter<Type,Size> Formatter;
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];
127 void push_back(
const Type & datum )
129 data[ leader++ ] = datum;
131 if( leader == follower )
134 follower %= size_fifo;
142 Type value = data[follower++];
143 follower %= size_fifo;
147 void fill(
const Type & d )
149 for(
unsigned int i=0; i<size_fifo; i++ ) data[i] = d;
162 unsigned int size()
const
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;
182 unsigned int size_fifo;