libxr 1.0
Want to be the best embedded framework
|
链表实现,用于存储和管理数据节点。 A linked list implementation for storing and managing data nodes. More...
#include <list.hpp>
Data Structures | |
class | BaseNode |
链表基础节点,所有节点都继承自该类。 Base node for the linked list, serving as a parent for all nodes. More... | |
class | Node |
数据节点模板,继承自 BaseNode ,用于存储具体数据类型。 Template data node that inherits from BaseNode to store specific data types. More... | |
Public Member Functions | |
List () noexcept | |
默认构造函数,初始化链表头节点。 Default constructor initializing the linked list head node. | |
~List () | |
析构函数,释放所有节点。 Destructor releasing all nodes. | |
void | Add (BaseNode &data) |
向链表添加一个节点。 Adds a node to the linked list. | |
uint32_t | Size () noexcept |
获取链表中的节点数量。 Gets the number of nodes in the linked list. | |
ErrorCode | Delete (BaseNode &data) noexcept |
从链表中删除指定的节点。 Deletes a specified node from the linked list. | |
template<typename Data , typename Func , SizeLimitMode LimitMode = SizeLimitMode::MORE> | |
ErrorCode | Foreach (Func func) |
遍历链表中的每个节点,并应用回调函数。 Iterates over each node in the list and applies a callback function. | |
template<typename Data , typename Func , SizeLimitMode LimitMode = SizeLimitMode::MORE> | |
ErrorCode | ForeachFromCallback (Func func, bool in_isr) |
在回调环境中遍历链表节点,并应用回调函数。 Iterates over each node in a callback environment and applies a function. | |
Private Attributes | |
BaseNode | head_ |
链表头节点。 The head node of the list. | |
LibXR::Mutex | mutex_ |
线程安全的互斥锁。 Thread-safe mutex. | |
链表实现,用于存储和管理数据节点。 A linked list implementation for storing and managing data nodes.
该类提供了基本的链表操作,包括添加、删除节点,以及遍历链表的功能, 具有线程安全的特性。 This class provides fundamental linked list operations, including adding, deleting nodes, and traversing the list, with thread-safety features.
|
inlinenoexcept |
默认构造函数,初始化链表头节点。 Default constructor initializing the linked list head node.
Definition at line 118 of file list.hpp.
|
inline |
析构函数,释放所有节点。 Destructor releasing all nodes.
向链表添加一个节点。 Adds a node to the linked list.
Definition at line 143 of file list.hpp.
|
inlinenoexcept |
从链表中删除指定的节点。 Deletes a specified node from the linked list.
ErrorCode
,指示操作是否成功。 Returns ErrorCode
, indicating whether the operation was successful. Definition at line 181 of file list.hpp.
|
inline |
遍历链表中的每个节点,并应用回调函数。 Iterates over each node in the list and applies a callback function.
Data | 存储的数据类型。 The type of stored data. |
Func | 回调函数类型。 The callback function type. |
LimitMode | 大小限制模式,默认为 MORE 。 Size limit mode, default is MORE . |
func | 需要应用于每个节点数据的回调函数。 The callback function to be applied to each node's data. |
ErrorCode
,指示操作是否成功。 Returns ErrorCode
, indicating whether the operation was successful. Definition at line 214 of file list.hpp.
在回调环境中遍历链表节点,并应用回调函数。 Iterates over each node in a callback environment and applies a function.
Data | 存储的数据类型。 The type of stored data. |
Func | 回调函数类型。 The callback function type. |
LimitMode | 大小限制模式,默认为 MORE 。 Size limit mode, default is MORE . |
func | 需要应用于每个节点数据的回调函数。 The callback function to be applied to each node's data. |
in_isr | 指示当前是否在中断服务例程(ISR)中。 Indicates whether the function is called in an ISR. |
ErrorCode
,指示操作是否成功。 Returns ErrorCode
, indicating whether the operation was successful. Definition at line 248 of file list.hpp.
|
inlinenoexcept |
获取链表中的节点数量。 Gets the number of nodes in the linked list.
|
private |
|
private |