mirror-chatterino2/src/messages/limitedqueuesnapshot.hpp

40 lines
702 B
C++
Raw Normal View History

#pragma once
2017-02-02 20:35:12 +01:00
#include <memory>
#include <vector>
namespace chatterino {
namespace messages {
template <typename T>
class LimitedQueueSnapshot
{
public:
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
{
}
std::size_t getLength()
2017-02-02 20:35:12 +01:00
{
return length;
2017-02-02 20:35:12 +01:00
}
T const &operator[](std::size_t index) const
2017-02-02 20:35:12 +01:00
{
return vector->at(index + offset);
2017-02-02 20:35:12 +01:00
}
private:
std::shared_ptr<std::vector<T>> vector;
2017-02-02 20:35:12 +01:00
std::size_t offset;
std::size_t length;
2017-02-02 20:35:12 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace messages
} // namespace chatterino