libxr 1.0
Want to be the best embedded framework
|
基础队列类,提供固定大小的循环缓冲区 (Base queue class providing a fixed-size circular buffer). More...
#include <queue.hpp>
Public Member Functions | |
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 |
Data Fields | |
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). | |
基础队列类,提供固定大小的循环缓冲区 (Base queue class providing a fixed-size circular buffer).
This class implements a circular queue that supports element insertion, retrieval, and batch operations. 该类实现了一个循环队列,支持元素插入、读取和批量操作。
构造函数,初始化队列 (Constructor to initialize the queue).
element_size | 队列中每个元素的大小 (Size of each element in the queue). |
length | 队列的最大容量 (Maximum capacity of the queue). |
buffer | 指向缓冲区的指针 (Pointer to the buffer). |
Definition at line 28 of file queue.hpp.
|
inline |
|
inline |
获取队列的空闲空间 (Get the available space in the queue).
Definition at line 325 of file queue.hpp.
|
inline |
|
inline |
访问指定索引的元素 (Access an element at a specified index).
index | 目标索引 (Target index). |
覆盖队列中的数据 (Overwrite the queue with new data).
data | 指向新数据的缓冲区 (Pointer to the new data buffer). |
ErrorCode::OK
(Operation result: ErrorCode::OK
on success). Definition at line 274 of file queue.hpp.
|
inline |
获取队列头部的元素但不移除 (Peek at the front element without removing it).
data | 指向存储数据的缓冲区 (Pointer to buffer where the data is stored). |
ErrorCode::OK
,队列为空时返回 ErrorCode::EMPTY
(Operation result: ErrorCode::OK
on success, ErrorCode::EMPTY
if empty). Definition at line 92 of file queue.hpp.
批量获取多个元素但不移除 (Peek at multiple elements without removing them).
data | 指向存储数据的缓冲区 (Pointer to buffer where the data is stored). |
size | 要获取的元素个数 (Number of elements to retrieve). |
ErrorCode::OK
,队列为空时返回 ErrorCode::EMPTY
(Operation result: ErrorCode::OK
on success, ErrorCode::EMPTY
if empty). Definition at line 245 of file queue.hpp.
移除队列头部的元素 (Pop the front element from the queue).
data | 指向存储数据的缓冲区 (Pointer to buffer where the removed data is stored). |
ErrorCode::OK
,队列为空时返回 ErrorCode::EMPTY
(Operation result: ErrorCode::OK
on success, ErrorCode::EMPTY
if empty). Definition at line 114 of file queue.hpp.
批量移除多个元素 (Pop multiple elements from the queue).
data | 指向存储数据的缓冲区 (Pointer to buffer where the removed data is stored). |
size | 要移除的元素个数 (Number of elements to remove). |
ErrorCode::OK
,队列为空时返回 ErrorCode::EMPTY
(Operation result: ErrorCode::OK
on success, ErrorCode::EMPTY
if empty). Definition at line 208 of file queue.hpp.
向队列中添加一个元素 (Push an element into the queue).
data | 指向要添加的数据 (Pointer to the data to be added). |
ErrorCode::OK
,队列满时返回 ErrorCode::FULL
(Operation result: ErrorCode::OK
on success, ErrorCode::FULL
if full). Definition at line 66 of file queue.hpp.
批量推入多个元素 (Push multiple elements into the queue).
data | 指向数据缓冲区 (Pointer to the data buffer). |
size | 要推入的元素个数 (Number of elements to push). |
ErrorCode::OK
,队列满时返回 ErrorCode::FULL
(Operation result: ErrorCode::OK
on success, ErrorCode::FULL
if full). Definition at line 175 of file queue.hpp.
|
inline |
|
inline |
获取队列中的元素个数 (Get the number of elements in the queue).
size_t LibXR::BaseQueue::length_ |
uint8_t* LibXR::BaseQueue::queue_array_ |