mirror-chatterino2/messages/limitedqueuesnapshot.h

43 lines
703 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:
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)
{
}
int
getLength()
{
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