2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
7 * @file CxxUtils/Ring.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief A simple ring buffer.
18 * @brief Clear the buffer and set its size.
19 * @param size New size of the buffer.
23 void Ring<T>::reset (size_t size)
32 * @brief Add a new item to the buffer.
33 * @param x Item to add.
37 void Ring<T>::push (const T& x)
40 if (m_pos >= m_data.size()) {
47 * @brief Return a copy of keys in the buffer.
49 * Immediately adjacent duplicates and unfilled entries will be removed,
50 * so the result may be smaller than the size of the buffer.
54 Ring<T>::getKeysDedup() const
56 size_t sz = m_data.size();
61 for (size_t pos = m_pos; pos < sz; ++pos) {
62 if (m_data[pos] != last_key) {
63 last_key = m_data[pos];
64 keys.push_back (last_key);
68 for (size_t pos = 0; pos < m_pos; ++pos) {
69 if (m_data[pos] != last_key) {
70 last_key = m_data[pos];
71 keys.push_back (last_key);
79 } // namespace CxxUtils