libxr 1.0
Want to be the best embedded framework
|
基于 BaseQueue 的泛型队列模板类 (Generic queue template class based on BaseQueue). More...
#include <queue.hpp>
Public Member Functions | |
Queue (size_t length) | |
构造函数,初始化队列 (Constructor to initialize the queue). | |
Queue (size_t length, uint8_t *buffer) | |
构造函数,初始化队列 (Constructor to initialize the queue). | |
Data & | operator[] (int32_t index) |
访问队列中的元素 (Access an element in the queue). | |
ErrorCode | Push (const Data &data) |
向队列中添加一个元素 (Push an element into the queue). | |
ErrorCode | Pop (Data &data) |
从队列中移除头部元素,并获取该元素的数据 (Remove the front element from the queue and retrieve its data). | |
ErrorCode | Pop () |
仅从队列中移除头部元素,不获取数据 (Remove the front element from the queue without retrieving data). | |
ErrorCode | Peek (Data &data) |
查看队列头部的元素但不移除 (Peek at the front element without removing it). | |
ErrorCode | PushBatch (const Data *data, size_t size) |
批量推入多个元素 (Push multiple elements into the queue). | |
ErrorCode | PopBatch (Data *data, size_t size) |
批量移除多个元素,并获取数据 (Pop multiple elements from the queue and retrieve data). | |
ErrorCode | PeekBatch (Data *data, size_t size) |
批量查看多个元素但不移除 (Peek at multiple elements without removing them). | |
ErrorCode | Overwrite (const Data &data) |
覆盖队列中的数据 (Overwrite the queue with new data). | |
![]() | |
BaseQueue (uint16_t element_size, size_t length, uint8_t *buffer) | |
构造函数,初始化队列 (Constructor to initialize the queue). | |
BaseQueue (uint16_t element_size, size_t length) | |
构造函数,初始化队列 (Constructor to initialize the queue). | |
~BaseQueue () | |
析构函数,释放队列内存 (Destructor to free queue memory). | |
void * | operator[] (uint32_t index) |
访问指定索引的元素 (Access an element at a specified index). | |
ErrorCode | Push (const void *data) |
向队列中添加一个元素 (Push an element into the queue). | |
ErrorCode | Peek (void *data) |
获取队列头部的元素但不移除 (Peek at the front element without removing it). | |
ErrorCode | Pop (void *data=nullptr) |
移除队列头部的元素 (Pop the front element from the queue). | |
int | GetLastElementIndex () |
获取队列中最后一个元素的索引 (Get the index of the last element in the queue). | |
int | GetFirstElementIndex () |
获取队列中第一个元素的索引 (Get the index of the first element in the queue). | |
ErrorCode | PushBatch (const void *data, size_t size) |
批量推入多个元素 (Push multiple elements into the queue). | |
ErrorCode | PopBatch (void *data, size_t size) |
批量移除多个元素 (Pop multiple elements from the queue). | |
ErrorCode | PeekBatch (void *data, size_t size) |
批量获取多个元素但不移除 (Peek at multiple elements without removing them). | |
ErrorCode | Overwrite (const void *data) |
覆盖队列中的数据 (Overwrite the queue with new data). | |
void | Reset () |
重置队列,清空所有数据 (Reset the queue and clear all data). | |
size_t | Size () |
获取队列中的元素个数 (Get the number of elements in the queue). | |
size_t | EmptySize () |
获取队列的空闲空间 (Get the available space in the queue). | |
BaseQueue (const BaseQueue &)=delete | |
BaseQueue | operator= (const BaseQueue &)=delete |
BaseQueue | operator= (BaseQueue &)=delete |
BaseQueue | operator= (const BaseQueue &&)=delete |
BaseQueue | operator= (BaseQueue &&)=delete |
Additional Inherited Members | |
![]() | |
uint8_t * | queue_array_ |
存储队列数据的数组 (Array storing queue data). | |
const uint16_t | ELEMENT_SIZE |
每个元素的大小 (Size of each element). | |
size_t | head_ = 0 |
头部索引 (Head index). | |
size_t | tail_ = 0 |
尾部索引 (Tail index). | |
bool | is_full_ = false |
队列是否已满 (Indicates if the queue is full). | |
size_t | length_ |
队列最大容量 (Maximum queue capacity). | |
基于 BaseQueue 的泛型队列模板类 (Generic queue template class based on BaseQueue).
This class provides a type-safe queue for storing elements of type Data
. It supports standard queue operations such as push, pop, peek, and batch operations. 该类提供一个类型安全的队列,用于存储 Data
类型的元素。 它支持标准的队列操作,如推入(Push)、弹出(Pop)、查看(Peek)以及批量操作。
Data | 队列存储的数据类型 (Type of data stored in the queue). |
|
inline |
构造函数,初始化队列 (Constructor to initialize the queue).
length | 队列的最大容量 (Maximum capacity of the queue). |
Definition at line 361 of file queue.hpp.
|
inline |
访问队列中的元素 (Access an element in the queue).
This function provides indexed access to elements in the queue. If the index is positive, it is relative to head_
(front of the queue). If negative, it is relative to tail_
(end of the queue). 该函数允许使用索引访问队列中的元素。 如果索引为正,则表示从 head_
(队列头部)开始的偏移量。 如果索引为负,则表示从 tail_
(队列尾部)开始的偏移量。
index | 访问的索引值 (Index to access). |
Definition at line 385 of file queue.hpp.
覆盖队列中的数据 (Overwrite the queue with new data).
data | 新数据 (New data to overwrite the queue). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success). Definition at line 486 of file queue.hpp.
|
inline |
查看队列头部的元素但不移除 (Peek at the front element without removing it).
data | 用于存储查看到的元素的引用 (Reference to store the peeked element). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::EMPTY
表示队列为空 (ErrorCode::EMPTY
if the queue is empty). Definition at line 436 of file queue.hpp.
|
inline |
批量查看多个元素但不移除 (Peek at multiple elements without removing them).
data | 指向存储数据的数组 (Pointer to the array where peeked elements will be stored). |
size | 要查看的元素个数 (Number of elements to retrieve). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::EMPTY
表示队列为空 (ErrorCode::EMPTY
if the queue is empty). Definition at line 474 of file queue.hpp.
|
inline |
仅从队列中移除头部元素,不获取数据 (Remove the front element from the queue without retrieving data).
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::EMPTY
表示队列为空 (ErrorCode::EMPTY
if the queue is empty). Definition at line 426 of file queue.hpp.
|
inline |
从队列中移除头部元素,并获取该元素的数据 (Remove the front element from the queue and retrieve its data).
data | 用于存储弹出元素的引用 (Reference to store the popped element). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::EMPTY
表示队列为空 (ErrorCode::EMPTY
if the queue is empty). Definition at line 417 of file queue.hpp.
|
inline |
批量移除多个元素,并获取数据 (Pop multiple elements from the queue and retrieve data).
data | 指向存储数据的数组 (Pointer to the array where popped elements will be stored). |
size | 要移除的元素个数 (Number of elements to remove). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::EMPTY
表示队列为空 (ErrorCode::EMPTY
if the queue is empty). Definition at line 462 of file queue.hpp.
向队列中添加一个元素 (Push an element into the queue).
data | 要推入的元素 (Element to push). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::FULL
表示队列已满 (ErrorCode::FULL
if the queue is full). Definition at line 407 of file queue.hpp.
|
inline |
批量推入多个元素 (Push multiple elements into the queue).
data | 指向数据数组 (Pointer to the array of elements to push). |
size | 要推入的元素个数 (Number of elements to push). |
ErrorCode::OK
表示成功 (ErrorCode::OK
on success).ErrorCode::FULL
表示队列已满 (ErrorCode::FULL
if the queue is full). Definition at line 447 of file queue.hpp.