File indexing completed on 2025-01-18 09:42:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
0020
0021 #include <boost/array.hpp>
0022
0023 namespace boost {
0024 namespace numeric {
0025 namespace odeint {
0026 namespace detail {
0027
0028 template< class T , size_t N >
0029 class rotating_buffer
0030 {
0031 public:
0032
0033 typedef T value_type;
0034 const static size_t dim = N;
0035
0036 rotating_buffer( void ) : m_first( 0 )
0037 { }
0038
0039 size_t size( void ) const
0040 {
0041 return dim;
0042 }
0043
0044 value_type& operator[]( size_t i )
0045 {
0046 return m_data[ get_index( i ) ];
0047 }
0048
0049 const value_type& operator[]( size_t i ) const
0050 {
0051 return m_data[ get_index( i ) ];
0052 }
0053
0054 void rotate( void )
0055 {
0056 if( m_first == 0 )
0057 m_first = dim-1;
0058 else
0059 --m_first;
0060 }
0061
0062 protected:
0063
0064 value_type m_data[N];
0065
0066 private:
0067
0068 size_t get_index( size_t i ) const
0069 {
0070 return ( ( i + m_first ) % dim );
0071 }
0072
0073 size_t m_first;
0074
0075 };
0076
0077
0078 }
0079 }
0080 }
0081 }
0082
0083
0084 #endif