3#include "libxr_def.hpp"
19template <
typename Data>
79 return ErrorCode::FULL;
100 return ErrorCode::EMPTY;
104 return ErrorCode::OK;
121 return ErrorCode::EMPTY;
125 return ErrorCode::OK;
143 return ErrorCode::EMPTY;
148 return ErrorCode::OK;
166 return ErrorCode::FULL;
172 return ErrorCode::OUT_OF_RANGE;
185 return ErrorCode::OK;
201 return ErrorCode::OUT_OF_RANGE;
210 return ErrorCode::OK;
互斥锁类,提供线程同步机制 (Mutex class providing thread synchronization mechanisms).
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
void Unlock()
解锁互斥锁 (Unlock the mutex).
线程安全的栈数据结构 / Thread-safe stack data structure
ErrorCode Delete(uint32_t index)
删除指定位置的数据 / Deletes data at a specified position
uint32_t EmptySize() const
获取栈的剩余可用空间 / Returns the remaining available space in the stack
ErrorCode Peek(Data &data)
获取栈顶数据但不弹出 / Retrieves the top data of the stack without popping
uint32_t depth_
栈的最大容量 / Maximum capacity of the stack
Data & operator[](int32_t index)
获取指定索引的元素 / Retrieves the element at a specified index
ErrorCode Insert(const Data &data, uint32_t index)
在指定位置插入数据 / Inserts data at a specified position
void Reset()
重置栈 / Resets the stack
Data * stack_
栈存储数组 / Stack storage array
ErrorCode Push(const Data &data)
向栈中推入数据 / Pushes data onto the stack
ErrorCode Pop(Data &data)
从栈中弹出数据 / Pops data from the stack
ErrorCode Pop()
从栈中弹出数据(不返回数据) / Pops data from the stack (without returning data)
uint32_t top_
当前栈顶索引 / Current top index of the stack
LibXR::Mutex mutex_
互斥锁,确保线程安全 / Mutex to ensure thread safety
Stack(uint32_t depth)
栈的构造函数 / Stack constructor
uint32_t Size() const
获取栈中当前元素数量 / Returns the number of elements currently in the stack
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值