Uniot Core
0.8.1
Loading...
Searching...
No Matches
ClearQueue< T > Class Template Reference

#include <ClearQueue.h>

Inheritance diagram for ClearQueue< T >:
[legend]

Classes

struct  node
 Node structure for the linked list implementation. More...
 

Public Types

typedef std::function< void(const T &)> VoidCallback
 Callback function type for forEach operations.
 

Public Member Functions

 ClearQueue (ClearQueue const &)=delete
 Deleted copy constructor to prevent copying.
 
void operator= (ClearQueue const &)=delete
 Deleted assignment operator to prevent copying.
 
 ClearQueue ()
 Constructs an empty queue.
 
virtual ~ClearQueue ()
 Destroys the queue and releases all allocated memory.
 
void push (const T &value)
 Adds an element to the end of the queue.
 
bool pushUnique (const T &value)
 Adds an element to the queue only if it doesn't already exist.
 
hardPop ()
 Removes and returns the element at the front of the queue.
 
const T & hardPeek () const
 Returns the element at the front of the queue without removing it.
 
pop (const T &errorCode)
 Safely removes and returns the element at the front of the queue.
 
const T & peek (const T &errorCode) const
 Safely returns the element at the front of the queue without removing it.
 
bool removeOne (const T &value)
 Removes the first occurrence of a specific value from the queue.
 
bool contains (const T &value) const
 Checks if the queue contains a specific value.
 
T * find (const T &value) const
 Finds and returns a pointer to the first occurrence of a value.
 
bool isEmpty () const
 Checks if the queue is empty.
 
size_t calcSize () const
 Calculate the number of elements in the queue by traversal.
 
void clean ()
 Removes all elements from the queue.
 
void forEach (VoidCallback callback) const
 Executes a callback function on each element in the queue.
 

Protected Types

typedef struct ClearQueue::nodepnode
 Node structure for the linked list implementation.
 

Protected Attributes

pnode mHead
 Pointer to the first node in the queue.
 
pnode mTail
 Pointer to the last node in the queue.
 

Member Typedef Documentation

◆ pnode

template<typename T>
typedef struct ClearQueue::node * ClearQueue< T >::pnode
protected

Node structure for the linked list implementation.

◆ VoidCallback

template<typename T>
typedef std::function<void(const T &)> ClearQueue< T >::VoidCallback

Callback function type for forEach operations.

Constructor & Destructor Documentation

◆ ClearQueue() [1/2]

template<typename T>
ClearQueue< T >::ClearQueue ( ClearQueue< T > const & )
delete

Deleted copy constructor to prevent copying.

◆ ClearQueue() [2/2]

template<typename T>
ClearQueue< T >::ClearQueue ( )

Constructs an empty queue.

◆ ~ClearQueue()

template<typename T>
ClearQueue< T >::~ClearQueue ( )
virtual

Destroys the queue and releases all allocated memory.

Member Function Documentation

◆ calcSize()

template<typename T>
size_t ClearQueue< T >::calcSize ( ) const

Calculate the number of elements in the queue by traversal.

This method traverses the entire queue to count elements. Useful for debugging or when you need an accurate count.

Return values
size_tThe actual number of elements in the queue

◆ clean()

template<typename T>
void ClearQueue< T >::clean ( )

Removes all elements from the queue.

◆ contains()

template<typename T>
bool ClearQueue< T >::contains ( const T & value) const

Checks if the queue contains a specific value.

Parameters
valueThe value to search for
Return values
trueThe value exists in the queue
falseThe value does not exist in the queue

◆ find()

template<typename T>
T * ClearQueue< T >::find ( const T & value) const

Finds and returns a pointer to the first occurrence of a value.

Parameters
valueThe value to search for
Return values
T*Pointer to the found element
nullptrThe value was not found in the queue

◆ forEach()

template<typename T>
void ClearQueue< T >::forEach ( VoidCallback callback) const

Executes a callback function on each element in the queue.

Parameters
callbackFunction to execute on each element

◆ hardPeek()

template<typename T>
const T & ClearQueue< T >::hardPeek ( ) const

Returns the element at the front of the queue without removing it.

Warning
This method assumes the queue is not empty. Call isEmpty() before using.
Return values
T&Reference to the front element of the queue

◆ hardPop()

template<typename T>
T ClearQueue< T >::hardPop ( )

Removes and returns the element at the front of the queue.

Warning
This method assumes the queue is not empty. Call isEmpty() before using.
Return values
TThe front element of the queue

◆ isEmpty()

template<typename T>
bool ClearQueue< T >::isEmpty ( ) const
inline

Checks if the queue is empty.

Return values
trueThe queue is empty
falseThe queue contains elements

◆ operator=()

template<typename T>
void ClearQueue< T >::operator= ( ClearQueue< T > const & )
delete

Deleted assignment operator to prevent copying.

◆ peek()

template<typename T>
const T & ClearQueue< T >::peek ( const T & errorCode) const

Safely returns the element at the front of the queue without removing it.

Parameters
errorCodeValue to return if the queue is empty
Return values
T&Reference to the front element of the queue
errorCodeThe value to return if the queue is empty

◆ pop()

template<typename T>
T ClearQueue< T >::pop ( const T & errorCode)

Safely removes and returns the element at the front of the queue.

Parameters
errorCodeValue to return if the queue is empty
Return values
TThe front element of the queue
errorCodeThe value to return if the queue is empty

◆ push()

template<typename T>
void ClearQueue< T >::push ( const T & value)

Adds an element to the end of the queue.

Parameters
valueThe value to add to the queue

◆ pushUnique()

template<typename T>
bool ClearQueue< T >::pushUnique ( const T & value)

Adds an element to the queue only if it doesn't already exist.

Parameters
valueThe value to add to the queue
Return values
trueThe element was added to the queue
falseThe element already exists in the queue

◆ removeOne()

template<typename T>
bool ClearQueue< T >::removeOne ( const T & value)

Removes the first occurrence of a specific value from the queue.

Parameters
valueThe value to remove
Return values
trueThe value was found and removed
falseThe value was not found in the queue

Member Data Documentation

◆ mHead

template<typename T>
pnode ClearQueue< T >::mHead
protected

Pointer to the first node in the queue.

◆ mTail

template<typename T>
pnode ClearQueue< T >::mTail
protected

Pointer to the last node in the queue.


The documentation for this class was generated from the following file: