mirror-chatterino2/messages/limitedqueuesnapshot.h

41 lines
674 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-12 17:46:44 +02:00
LimitedQueueSnapshot(std::shared_ptr<std::vector<T>> ptr, int offset, int length)
: vector(ptr)
2017-02-02 20:35:12 +01:00
, offset(offset)
, length(length)
{
}
2017-04-12 17:46:44 +02:00
int getLength()
2017-02-02 20:35:12 +01:00
{
return this->length;
2017-02-02 20:35:12 +01:00
}
T const &operator[](int index) const
{
return this->vector->at(index + this->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
int offset;
int length;
};
}
}
#endif // LIMITEDQUEUESNAPSHOT_H