ESyS-Particle  2.3.2
RingBuffer.hpp
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 template< typename T>
15 {
16  m_buffer=vector<T>(s);
17  m_idx=0;
18  m_size=s;
19 }
20 
21 template< typename T>
23 {
24  int real_idx=(m_idx+i)%m_size;
25  return m_buffer[real_idx];
26 }
27 
28 template< typename T>
30 {
31  int real_idx=(m_idx+i)%m_size;
32  return m_buffer[real_idx];
33 }
34 
35 template< typename T>
36 void RingBuffer<T>::insert(const T& data)
37 {
38  m_idx=(m_idx+1)%m_size;
39  m_buffer[m_idx]=data;
40 }