ATLAS Offline Software
Ring.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
4 */
5 /*
6  */
15 #ifndef CXXUTILS_RING_H
16 #define CXXUTILS_RING_H
17 
18 
19 #include <vector>
20 #include <cstddef>
21 
22 
23 namespace CxxUtils {
24 
25 
38 template <class T>
39 class Ring
40 {
41 public:
46  void reset (size_t size);
47 
48 
53  void push (const T& x);
54 
55 
62  std::vector<T> getKeysDedup() const;
63 
64 
65 private:
66  std::vector<T> m_data;
67  size_t m_pos = 0;
68 };
69 
70 
71 } // namespace CxxUtils
72 
73 
74 #include "CxxUtils/Ring.icc"
75 
76 
77 #endif // not CXXUTILS_RING_H
CxxUtils::Ring::getKeysDedup
std::vector< T > getKeysDedup() const
Return a copy of keys in the buffer.
Ring.icc
CxxUtils::Ring
A very simple ring buffer.
Definition: Ring.h:40
x
#define x
CxxUtils::Ring::reset
void reset(size_t size)
Clear the buffer and set its size.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CxxUtils
Definition: aligned_vector.h:29
CxxUtils::Ring::m_data
std::vector< T > m_data
Definition: Ring.h:66
CxxUtils::Ring::push
void push(const T &x)
Add a new item to the buffer.
CxxUtils::Ring::m_pos
size_t m_pos
Definition: Ring.h:67