Chatterino
LimitedQueueSnapshot.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <boost/circular_buffer.hpp>
4 
5 #include <cassert>
6 #include <memory>
7 #include <vector>
8 
9 namespace chatterino {
10 
11 template <typename T>
12 class LimitedQueue;
13 
14 template <typename T>
16 {
17 private:
18  friend class LimitedQueue<T>;
19 
20  LimitedQueueSnapshot(const boost::circular_buffer<T> &buf)
21  : buffer_(buf.begin(), buf.end())
22  {
23  }
24 
25 public:
26  LimitedQueueSnapshot() = default;
27 
28  size_t size() const
29  {
30  return this->buffer_.size();
31  }
32 
33  const T &operator[](size_t index) const
34  {
35  return this->buffer_[index];
36  }
37 
38  auto begin() const
39  {
40  return this->buffer_.begin();
41  }
42 
43  auto end() const
44  {
45  return this->buffer_.end();
46  }
47 
48  auto rbegin() const
49  {
50  return this->buffer_.rbegin();
51  }
52 
53  auto rend() const
54  {
55  return this->buffer_.rend();
56  }
57 
58 private:
59  std::vector<T> buffer_;
60 };
61 
62 } // namespace chatterino
auto end() const
Definition: LimitedQueueSnapshot.hpp:43
Definition: LimitedQueue.hpp:16
const T & operator[](size_t index) const
Definition: LimitedQueueSnapshot.hpp:33
Definition: LimitedQueueSnapshot.hpp:15
Definition: Application.cpp:48
auto rbegin() const
Definition: LimitedQueueSnapshot.hpp:48
size_t size() const
Definition: LimitedQueueSnapshot.hpp:28
auto rend() const
Definition: LimitedQueueSnapshot.hpp:53
auto begin() const
Definition: LimitedQueueSnapshot.hpp:38