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)
|
2017-02-07 20:40:43 +01:00
|
|
|
: 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
|
|
|
{
|
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
|