mirror-chatterino2/src/messages/limitedqueuesnapshot.h

41 lines
713 B
C
Raw Normal View History

2017-02-02 20:35:12 +01:00
#ifndef LIMITEDQUEUESNAPSHOT_H
#define LIMITEDQUEUESNAPSHOT_H
#include <memory>
#include <vector>
namespace chatterino {
namespace messages {
template <typename T>
class LimitedQueueSnapshot
{
public:
2017-04-14 17:47:28 +02:00
LimitedQueueSnapshot(std::shared_ptr<std::vector<T>> vector, int offset, int size)
: _vector(vector)
, _offset(offset)
, _length(size)
2017-02-02 20:35:12 +01:00
{
}
2017-04-14 17:47:28 +02:00
int getSize()
2017-02-02 20:35:12 +01:00
{
2017-04-14 17:47:28 +02:00
return _length;
2017-02-02 20:35:12 +01:00
}
T const &operator[](int index) const
{
2017-04-14 17:47:28 +02:00
return _vector->at(index + _offset);
2017-02-02 20:35:12 +01:00
}
private:
2017-04-14 17:47:28 +02:00
std::shared_ptr<std::vector<T>> _vector;
2017-02-02 20:35:12 +01:00
2017-04-14 17:47:28 +02:00
int _offset;
int _length;
2017-02-02 20:35:12 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace messages
} // namespace chatterino
2017-02-02 20:35:12 +01:00
#endif // LIMITEDQUEUESNAPSHOT_H