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

#include <IterableQueue.h>

Inheritance diagram for IterableQueue< T >:
[legend]

Public Member Functions

void begin () const
 Initialize the iterator to the beginning of the queue.
 
bool isEnd () const
 Check if the iterator has reached the end of the queue.
 
const T & next () const
 Move to the next element and return the current element.
 
const T & current () const
 Access the current element without moving the iterator.
 
bool deleteCurrent ()
 Remove the current element from the queue.
 
- Public Member Functions inherited from ClearQueue< T >
 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 Attributes

ClearQueue< T >::pnode mCurrent
 Pointer to the current node during iteration.
 
- Protected Attributes inherited from ClearQueue< T >
pnode mHead
 Pointer to the first node in the queue.
 
pnode mTail
 Pointer to the last node in the queue.
 

Additional Inherited Members

- Public Types inherited from ClearQueue< T >
typedef std::function< void(const T &)> VoidCallback
 Callback function type for forEach operations.
 
- Protected Types inherited from ClearQueue< T >
typedef struct ClearQueue::nodepnode
 Node structure for the linked list implementation.
 

Member Function Documentation

◆ begin()

template<typename T>
void IterableQueue< T >::begin ( ) const

Initialize the iterator to the beginning of the queue.

Sets the current position to the head of the queue for iteration.

◆ current()

template<typename T>
const T & IterableQueue< T >::current ( ) const

Access the current element without moving the iterator.

Return values
T&The value at the current iterator position

◆ deleteCurrent()

template<typename T>
bool IterableQueue< T >::deleteCurrent ( )

Remove the current element from the queue.

Removes the element at the current iterator position and advances the iterator to the next element. If the current element is the last element, the iterator will point to the end.

Return values
trueThe element was successfully removed
falseThe iterator was at the end or queue was empty

◆ isEnd()

template<typename T>
bool IterableQueue< T >::isEnd ( ) const

Check if the iterator has reached the end of the queue.

Return values
trueIf the iterator has reached the end (no more elements)
falseIf there are still elements to iterate through

◆ next()

template<typename T>
const T & IterableQueue< T >::next ( ) const

Move to the next element and return the current element.

Advances the iterator to the next position and returns the value at the previous position.

Return values
T&The value of the current element before advancing

Member Data Documentation

◆ mCurrent

template<typename T>
ClearQueue<T>::pnode IterableQueue< T >::mCurrent
mutableprotected

Pointer to the current node during iteration.

This mutable member allows modification within const methods to support iteration in const contexts.


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