15 #ifndef ECL_CONTAINERS_PUSH_AND_POP_FIXED_HPP_ 16 #define ECL_CONTAINERS_PUSH_AND_POP_FIXED_HPP_ 24 #include <ecl/config/macros.hpp> 25 #include <ecl/errors/compile_time_assert.hpp> 26 #include <ecl/exceptions/standard_exception.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) ];
111 void operator() (
const PushAndPop<Type,Size> & otherOne )
113 leader = otherOne.leader;
114 follower = otherOne.follower;
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;
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;
#define LOC
Stringify the line of code you are at.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
ecl_geometry_PUBLIC int size(const Trajectory2D &trajectory)
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.
const GenericPointer< typename T::ValueType > T2 value
MatrixFormatter< Derived, Scalar > Formatter