]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/stepper/detail/rotating_buffer.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / stepper / detail / rotating_buffer.hpp
CommitLineData
7c673cae
FG
1/*
2 [auto_generated]
3 boost/numeric/odeint/stepper/detail/rotating_buffer.hpp
4
5 [begin_description]
6 Implemetation of a rotating (cyclic) buffer for use in the Adam Bashforth stepper
7 [end_description]
8
9 Copyright 2011 Karsten Ahnert
10 Copyright 2011 Mario Mulansky
11
12 Distributed under the Boost Software License, Version 1.0.
13 (See accompanying file LICENSE_1_0.txt or
14 copy at http://www.boost.org/LICENSE_1_0.txt)
15 */
16
17
18#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
19#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
20
21#include <boost/array.hpp>
22
23namespace boost {
24namespace numeric {
25namespace odeint {
26namespace detail {
27
28template< class T , size_t N >
29class rotating_buffer
30{
31public:
32
33 typedef T value_type;
34 const static size_t dim = N;
35
36 rotating_buffer( void ) : m_first( 0 )
37 { }
38
39 size_t size( void ) const
40 {
41 return dim;
42 }
43
44 value_type& operator[]( size_t i )
45 {
46 return m_data[ get_index( i ) ];
47 }
48
49 const value_type& operator[]( size_t i ) const
50 {
51 return m_data[ get_index( i ) ];
52 }
53
54 void rotate( void )
55 {
56 if( m_first == 0 )
57 m_first = dim-1;
58 else
59 --m_first;
60 }
61
62protected:
63
64 value_type m_data[N];
65
66private:
67
68 size_t get_index( size_t i ) const
69 {
70 return ( ( i + m_first ) % dim );
71 }
72
73 size_t m_first;
74
75};
76
77
78} // detail
79} // odeint
80} // numeric
81} // boost
82
83
84#endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED