104 T
pop(
const T &errorCode);
113 const T &
peek(
const T &errorCode)
const;
211 mTail->next =
nullptr;
212 mTail->value = value;
222 T value =
mHead->value;
227 if (
mHead ==
nullptr) {
258 if (
mHead->value == value) {
262 for (
pnode cur =
mHead; cur->next !=
nullptr; cur = cur->next) {
263 if (cur->next->value == value) {
264 pnode newNext = cur->next->next;
268 if (newNext ==
nullptr) {
281 for (
pnode cur =
mHead; cur !=
nullptr; cur = cur->next) {
282 if (cur->value == value) {
291 for (
pnode cur =
mHead; cur !=
nullptr; cur = cur->next) {
292 if (cur->value == value) {
293 return &(cur->value);
301 return mHead ==
nullptr;
307 for (
pnode cur =
mHead; cur !=
nullptr; cur = cur->next) {
326 for (
pnode cur =
mHead; cur !=
nullptr; cur = cur->next) {
327 callback(cur->value);
void forEach(VoidCallback callback) const
Executes a callback function on each element in the queue.
Definition ClearQueue.h:325
ClearQueue(ClearQueue const &)=delete
Deleted copy constructor to prevent copying.
T * find(const T &value) const
Finds and returns a pointer to the first occurrence of a value.
Definition ClearQueue.h:290
size_t calcSize() const
Calculate the number of elements in the queue by traversal.
Definition ClearQueue.h:305
bool contains(const T &value) const
Checks if the queue contains a specific value.
Definition ClearQueue.h:280
bool removeOne(const T &value)
Removes the first occurrence of a specific value from the queue.
Definition ClearQueue.h:256
void push(const T &value)
Adds an element to the end of the queue.
Definition ClearQueue.h:207
T pop(const T &errorCode)
Safely removes and returns the element at the front of the queue.
Definition ClearQueue.h:240
bool pushUnique(const T &value)
Adds an element to the queue only if it doesn't already exist.
Definition ClearQueue.h:198
T hardPop()
Removes and returns the element at the front of the queue.
Definition ClearQueue.h:221
struct ClearQueue::node * pnode
Node structure for the linked list implementation.
const T & peek(const T &errorCode) const
Safely returns the element at the front of the queue without removing it.
Definition ClearQueue.h:248
pnode mTail
Pointer to the last node in the queue.
Definition ClearQueue.h:182
pnode mHead
Pointer to the first node in the queue.
Definition ClearQueue.h:181
bool isEmpty() const
Checks if the queue is empty.
Definition ClearQueue.h:300
virtual ~ClearQueue()
Destroys the queue and releases all allocated memory.
Definition ClearQueue.h:193
std::function< void(const T &)> VoidCallback
Callback function type for forEach operations.
Definition ClearQueue.h:43
const T & hardPeek() const
Returns the element at the front of the queue without removing it.
Definition ClearQueue.h:235
void operator=(ClearQueue const &)=delete
Deleted assignment operator to prevent copying.
void clean()
Removes all elements from the queue.
Definition ClearQueue.h:314
ClearQueue()
Constructs an empty queue.
Definition ClearQueue.h:187
Node structure for the linked list implementation.
Definition ClearQueue.h:176
T value
The stored value.
Definition ClearQueue.h:177
node * next
Pointer to the next node.
Definition ClearQueue.h:178