6#include "queue_base.hpp"
7#include "queue_typed_base.hpp"
23template <
typename Data>
52 Queue(
size_t length, uint8_t* buffer) :
QueueBase(sizeof(Data), length, buffer) {}
提供固定大小循环缓冲区的字节 FIFO 队列。 Byte FIFO queue providing a fixed-size circular buffer.
const uint16_t ELEMENT_SIZE
单个元素的字节数 / Byte size of one element.
uint8_t * queue_array_
队列数据缓冲区 / Queue data buffer.
ErrorCode PopBatchBytes(void *data, size_t size)
按字节批量出队多个元素 / Dequeue multiple elements by bytes.
ErrorCode OverwriteBytes(const void *data)
清空当前状态后,用一个新元素覆盖队列内容。 Reset the queue state and overwrite it with one new element.
ErrorCode PeekBatchBytes(void *data, size_t size)
按字节批量查看多个元素但不出队。 Peek multiple elements by bytes without dequeuing them.
size_t MaxSize() const
获取队列最大容量 / Get the maximum queue capacity.
ErrorCode PushBatchBytes(const void *data, size_t size)
按字节批量入队多个元素 / Enqueue multiple elements by bytes.
size_t length_
队列最大容量 / Maximum queue capacity.
size_t head_
当前队头物理槽位下标 / Physical slot index of the current head.
ErrorCode PeekBytes(void *data)
按字节查看队头元素但不出队。 Peek the front element by bytes without dequeuing it.
基于 QueueBase 的泛型队列模板类。 Generic queue template class based on QueueBase.
ErrorCode PopBatch(Data *data, size_t size)
批量移除多个元素并复制到输出数组。 Pop multiple elements and copy them into the output array.
Queue(size_t length, uint8_t *buffer)
使用外部缓冲区构造强类型队列。 Construct one typed queue with an external buffer.
ErrorCode PeekBatch(Data *data, size_t size)
批量查看多个元素但不移除 / Peek multiple elements without removing them.
ErrorCode PushBatch(const Data *data, size_t size)
批量推入多个元素 / Push multiple elements into the queue.
ErrorCode Peek(Data &data)
查看队头元素但不出队 / Peek the front element without removing it.
ErrorCode Overwrite(const Data &data)
清空当前状态后,用一个新元素覆盖队列内容。 Reset the queue state and overwrite it with one new element.
size_t MaxSize() const
获取队列最大容量 / Get the maximum queue capacity.
Queue(size_t length)
构造一个由内部缓冲区支撑的强类型队列。 Construct one typed queue backed by an internal buffer.
Data & operator[](int32_t index)
按逻辑索引访问队列中的元素 / Access an element in the queue by logical index.
强类型队列的公共薄包装 / Common thin wrapper for typed queues.
ErrorCode Push(const Data &item)
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes