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 );
105 data.resize( size_fifo );
162 return reverse_iterator(end());
171 return const_reverse_iterator(end());
180 return reverse_iterator(begin());
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
iterator begin() ecl_assert_throw_decl(StandardException)
Embedded control libraries.
std::reverse_iterator< iterator > reverse_iterator
Surpport push and pack operation.
const_reverse_iterator rbegin() const ecl_assert_throw_decl(StandardException)
reverse_iterator rend() ecl_assert_throw_decl(StandardException)
std::ptrdiff_t difference_type
unsigned int size() const
PushAndPop()
Default constructor.
#define ecl_assert_throw(expression, exception)
const Type * const_iterator
A simple fifo implementation.
reverse_iterator rbegin() ecl_assert_throw_decl(StandardException)
iterator end() ecl_assert_throw_decl(StandardException)
const_reverse_iterator rend() const ecl_assert_throw_decl(StandardException)
formatters::PushAndPopFormatter< Type, DynamicStorage > Formatter
Formatter for this class.
const Type & const_reference
#define ecl_assert_throw_decl(exception)
void resize(unsigned int length)
void push_back(const Type &datum)
Pushes an element onto the back of the container.
const_iterator begin() const ecl_assert_throw_decl(StandardException)
ecl::Array< Type, Size+1 > data
unsigned int asize()
The size allocated in memory for the fifo.
PushAndPop(const unsigned int length, const Type &d) ecl_assert_throw_decl(StandardException)
const_iterator end() const ecl_assert_throw_decl(StandardException)
PushAndPop(const unsigned int length) ecl_assert_throw_decl(StandardException)