![]() |
|
Uniot Core
|
| 0.8.1 |
#include <LimitedQueue.h>
Public Member Functions | |
| LimitedQueue () | |
| Construct a new LimitedQueue with default settings. | |
| size_t | limit () const |
| Get the current size limit of the queue. | |
| size_t | size () const |
| Get the current number of elements in the queue. | |
| void | limit (size_t limit) |
| Set the maximum size limit for the queue. | |
| bool | isFull () const |
| Check if the queue has reached its size limit. | |
| void | applyLimit () |
| Enforce the size limit by removing oldest elements if necessary. | |
| void | pushLimited (const T &value) |
| Add an element to the queue while respecting the size limit. | |
| T | popLimited (const T &errorCode) |
| Remove and return the oldest element from the queue. | |
| size_t | calcSize () const |
| Recalculate the size by traversing the queue. | |
| void | clean () |
| Remove all elements 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. | |
| T | 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. | |
| T | 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. | |
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::node * | pnode |
| Node structure for the linked list implementation. | |
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. | |
|
inline |
Construct a new LimitedQueue with default settings.
Creates an empty queue with a size limit of 0 (unlimited by default)
|
inline |
Enforce the size limit by removing oldest elements if necessary.
Removes elements from the front of the queue until the size is within limits
|
inline |
Recalculate the size by traversing the queue.
This method should be used if the size tracking may have become inconsistent
| size_t | The actual number of elements in the queue |
|
inline |
Remove all elements from the queue.
Resets the queue to its initial empty state
|
inline |
Check if the queue has reached its size limit.
| true | If the queue is full (size >= limit) |
| false | If the queue has space for more elements |
|
inline |
Get the current size limit of the queue.
| size_t | The maximum number of elements the queue can hold |
|
inline |
Set the maximum size limit for the queue.
If the new limit is smaller than the current size, oldest elements are automatically removed.
| limit | The maximum number of elements the queue can hold |
|
inline |
Remove and return the oldest element from the queue.
| errorCode | Value to return if the queue is empty |
| T | The removed element |
| errorCode | The value to return if the queue is empty |
|
inline |
Add an element to the queue while respecting the size limit.
If adding the element would exceed the size limit, the oldest element is removed first
| value | The element to add to the queue |
|
inline |
Get the current number of elements in the queue.
| size_t | The current number of elements |