ATLAS Offline Software
Loading...
Searching...
No Matches
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 */
13
14
15#ifndef CXXUTILS_RING_H
16#define CXXUTILS_RING_H
17
18
19#include <vector>
20#include <cstddef>
21
22
23namespace CxxUtils {
24
25
38template <class T>
39class Ring
40{
41public:
46 void reset (size_t size);
47
48
53 void push (const T& x);
54
55
62 std::vector<T> getKeysDedup() const;
63
64
65private:
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
#define x
A very simple ring buffer.
Definition Ring.h:40
void reset(size_t size)
Clear the buffer and set its size.
std::vector< key_type > m_data
Definition Ring.h:66
std::vector< T > getKeysDedup() const
Return a copy of keys in the buffer.
void push(const T &x)
Add a new item to the buffer.