15 auto tmp = pos->next_;
50 if (pos->next_ == &data)
52 pos->next_ = data.next_;
59 return ErrorCode::NOT_FOUND;
链表基础节点,所有节点都继承自该类。 Base node for the linked list, serving as a parent for all nodes.
BaseNode * next_
指向下一个节点的指针。 Pointer to the next node.
~BaseNode()
析构函数,确保节点不会在列表中残留。 Destructor ensuring the node does not remain in the list.
BaseNode(size_t size)
构造 BaseNode 并设置节点大小。 Constructs a BaseNode and sets its size.
LibXR::Mutex mutex_
线程安全的互斥锁。 Thread-safe mutex.
ErrorCode Delete(BaseNode &data) noexcept
从链表中删除指定的节点。 Deletes a specified node from the linked list.
uint32_t Size() noexcept
获取链表中的节点数量。 Gets the number of nodes in the linked list.
~List()
析构函数,释放所有节点。 Destructor releasing all nodes.
void Add(BaseNode &data)
向链表添加一个节点。 Adds a node to the linked list.
List() noexcept
默认构造函数,初始化链表头节点。 Default constructor initializing the linked list head node.
BaseNode head_
链表头节点。 The head node of the list.
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
void Unlock()
解锁互斥锁 (Unlock the mutex).