mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
41 lines
713 B
C++
41 lines
713 B
C++
#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>> vector, int offset, int size)
|
|
: _vector(vector)
|
|
, _offset(offset)
|
|
, _length(size)
|
|
{
|
|
}
|
|
|
|
int getSize()
|
|
{
|
|
return _length;
|
|
}
|
|
|
|
T const &operator[](int index) const
|
|
{
|
|
return _vector->at(index + _offset);
|
|
}
|
|
|
|
private:
|
|
std::shared_ptr<std::vector<T>> _vector;
|
|
|
|
int _offset;
|
|
int _length;
|
|
};
|
|
} // namespace messages
|
|
} // namespace chatterino
|
|
|
|
#endif // LIMITEDQUEUESNAPSHOT_H
|