2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-02-02 20:35:12 +01:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace messages {
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class LimitedQueueSnapshot
|
|
|
|
{
|
|
|
|
public:
|
2017-06-26 16:41:20 +02:00
|
|
|
LimitedQueueSnapshot(std::shared_ptr<std::vector<T>> _vector, std::size_t _offset,
|
|
|
|
std::size_t _size)
|
|
|
|
: vector(_vector)
|
|
|
|
, offset(_offset)
|
|
|
|
, length(_size)
|
2017-02-02 20:35:12 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
std::size_t getLength()
|
2017-02-02 20:35:12 +01:00
|
|
|
{
|
2017-06-26 16:41:20 +02:00
|
|
|
return length;
|
2017-02-02 20:35:12 +01:00
|
|
|
}
|
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
T const &operator[](std::size_t index) const
|
2017-02-02 20:35:12 +01:00
|
|
|
{
|
2017-06-26 16:41:20 +02:00
|
|
|
return vector->at(index + offset);
|
2017-02-02 20:35:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-06-26 16:41:20 +02:00
|
|
|
std::shared_ptr<std::vector<T>> vector;
|
2017-02-02 20:35:12 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
std::size_t offset;
|
|
|
|
std::size_t length;
|
2017-02-02 20:35:12 +01:00
|
|
|
};
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace messages
|
|
|
|
} // namespace chatterino
|