Chris@16: /* Chris@16: [auto_generated] Chris@16: boost/numeric/odeint/stepper/detail/rotating_buffer.hpp Chris@16: Chris@16: [begin_description] Chris@16: Implemetation of a rotating (cyclic) buffer for use in the Adam Bashforth stepper Chris@16: [end_description] Chris@16: Chris@101: Copyright 2011 Karsten Ahnert Chris@101: Copyright 2011 Mario Mulansky Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. Chris@16: (See accompanying file LICENSE_1_0.txt or Chris@16: copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: Chris@16: Chris@16: #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED Chris@16: #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace numeric { Chris@16: namespace odeint { Chris@16: namespace detail { Chris@16: Chris@16: template< class T , size_t N > Chris@16: class rotating_buffer Chris@16: { Chris@16: public: Chris@16: Chris@16: typedef T value_type; Chris@16: const static size_t dim = N; Chris@16: Chris@16: rotating_buffer( void ) : m_first( 0 ) Chris@16: { } Chris@16: Chris@16: size_t size( void ) const Chris@16: { Chris@16: return dim; Chris@16: } Chris@16: Chris@16: value_type& operator[]( size_t i ) Chris@16: { Chris@16: return m_data[ get_index( i ) ]; Chris@16: } Chris@16: Chris@16: const value_type& operator[]( size_t i ) const Chris@16: { Chris@16: return m_data[ get_index( i ) ]; Chris@16: } Chris@16: Chris@16: void rotate( void ) Chris@16: { Chris@16: if( m_first == 0 ) Chris@16: m_first = dim-1; Chris@16: else Chris@16: --m_first; Chris@16: } Chris@16: Chris@16: protected: Chris@16: Chris@16: value_type m_data[N]; Chris@16: Chris@16: private: Chris@16: Chris@16: size_t get_index( size_t i ) const Chris@16: { Chris@16: return ( ( i + m_first ) % dim ); Chris@16: } Chris@16: Chris@16: size_t m_first; Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: } // detail Chris@16: } // odeint Chris@16: } // numeric Chris@16: } // boost Chris@16: Chris@16: Chris@16: #endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED