Labrador/Desktop_Interface/isobufferbuffer.h

28 lines
609 B
C
Raw Normal View History

#ifndef ISOBUFFERBUFFER_H
#define ISOBUFFERBUFFER_H
//isobufferbuffer is a buffer designed for getting the last n things added in reverse order, in O(1) time.
#include <QDebug>
#include <stdlib.h>
2018-11-05 23:15:48 +00:00
#include <string>
class isoBufferBuffer
{
public:
2018-11-05 23:15:48 +00:00
isoBufferBuffer(uint32_t length);
2018-11-05 23:55:45 +00:00
void add(uint8_t newByte);
void add(char newChar);
2018-11-05 23:15:48 +00:00
void add(std::string newString);
char *get(uint32_t length);
uint32_t getNumCharsInBuffer();
private:
2018-11-05 23:15:48 +00:00
uint32_t bufferLength;
uint32_t mid;
uint32_t ptr;
char *buffer;
2018-11-05 23:15:48 +00:00
uint32_t numCharsInBuffer = 0;
};
#endif // ISOBUFFERBUFFER_H