6#include "libxr_def.hpp"
29 QueueBase(uint16_t element_size,
size_t length, uint8_t* buffer);
39 QueueBase(uint16_t element_size,
size_t length);
53 [[nodiscard]]
void*
operator[](uint32_t index);
149 [[nodiscard]]
size_t Size()
const;
size_t EmptySize() const
获取当前剩余空槽数。
bool is_full_
当前队列是否已满。 Whether the queue is currently full.
ErrorCode PushBytes(const void *data)
按字节入队一个元素。
QueueBase & operator=(QueueBase &&)
禁止移动赋值。 Non-move-assignable.
const uint16_t ELEMENT_SIZE
单个元素的字节数。 Byte size of one element.
uint8_t * queue_array_
队列数据缓冲区。 Queue data buffer.
ErrorCode PopBatchBytes(void *data, size_t size)
按字节批量出队多个元素。
int GetLastElementIndex() const
获取当前最后一个已入队元素的物理槽位下标。
QueueBase(const QueueBase &)
禁止拷贝构造。 Non-copyable.
QueueBase(uint16_t element_size, size_t length, uint8_t *buffer)
使用外部缓冲区构造队列。
ErrorCode OverwriteBytes(const void *data)
清空当前状态后,用一个新元素覆盖队列内容。
ErrorCode PeekBatchBytes(void *data, size_t size)
按字节批量查看多个元素但不出队。
size_t MaxSize() const
获取队列最大容量。
QueueBase & operator=(QueueBase &)
禁止同类型左值赋值重载。 Non-copy-assignable overload for non-const lvalues.
void * operator[](uint32_t index)
访问指定物理槽位的原始元素地址。
QueueBase & operator=(const QueueBase &)
禁止拷贝赋值。 Non-copy-assignable.
size_t Size() const
获取当前已存储元素个数。
QueueBase & operator=(const QueueBase &&)
禁止移动赋值(const rvalue 形式)。 Non-move-assignable (const rvalue form).
ErrorCode PushBatchBytes(const void *data, size_t size)
按字节批量入队多个元素。
int GetFirstElementIndex() const
获取当前第一个已入队元素的物理槽位下标。
size_t length_
队列最大容量。 Maximum queue capacity.
size_t head_
当前队头物理槽位下标。 Physical slot index of the current head.
bool own_buffer_
是否由当前队列拥有缓冲区。 Whether this queue owns the buffer.
size_t tail_
下一个待写入物理槽位下标。 Physical slot index of the next enqueue position.
ErrorCode PopBytes(void *data=nullptr)
按字节出队一个元素;传空指针时仅丢弃队头。
ErrorCode PeekBytes(void *data)
按字节查看队头元素但不出队。