9List::List() noexcept : head_(0) { head_.next_ = &head_; }
13 for (
auto pos = head_.
next_; pos != &head_;)
15 auto tmp = pos->next_;
20 head_.
next_ =
nullptr;
36 for (
auto pos = head_.
next_; pos != &head_; pos = pos->
next_)
48 for (
auto pos = &head_; pos->
next_ != &head_; pos = pos->
next_)
50 if (pos->next_ == &data)
52 pos->next_ = data.next_;
链表基础节点,所有节点都继承自该类。 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.
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.
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 Lock the mutex, blocking if it is already locked.
void Unlock()
解锁互斥锁 Unlock the mutex.
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
@ NOT_FOUND
未找到 / Not found
@ OK
操作成功 / Operation successful