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)
|
2017-02-07 20:40:43 +01:00
|
|
|
: vector(ptr)
|
2017-02-02 20:35:12 +01:00
|
|
|
, offset(offset)
|
|
|
|
, length(length)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
getLength()
|
|
|
|
{
|
2017-02-07 20:40:43 +01:00
|
|
|
return this->length;
|
2017-02-02 20:35:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
T const &operator[](int index) const
|
|
|
|
{
|
2017-02-07 20:40:43 +01:00
|
|
|
return this->vector->at(index + this->offset);
|
2017-02-02 20:35:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-02-07 20:40:43 +01:00
|
|
|
std::shared_ptr<std::vector<T>> vector;
|
2017-02-02 20:35:12 +01:00
|
|
|
|
|
|
|
int offset;
|
|
|
|
int length;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // LIMITEDQUEUESNAPSHOT_H
|