![]() |
|
Uniot Core
|
| 0.8.1 |
#include <Map.h>
Public Types | |
| using | MapItem = Pair<T_Key, T_Value> |
| Type alias for a key-value pair in the map. | |
Public Types inherited from ClearQueue< Pair< T_Key, T_Value > > | |
| typedef std::function< void(const Pair< T_Key, T_Value > &)> | VoidCallback |
| Callback function type for forEach operations. | |
Public Member Functions | |
| bool | put (const T_Key &key, const T_Value &value) |
| Inserts a key-value pair into the map. | |
| const T_Value & | get (const T_Key &key, const T_Value &defaultValue={}) const |
| Retrieves the value associated with a key. | |
| bool | exist (const T_Key &key) const |
| Checks if a key exists in the map. | |
| bool | remove (const T_Key &key) |
| Removes a key-value pair from the map. | |
Public Member Functions inherited from IterableQueue< Pair< T_Key, T_Value > > | |
| 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 Pair< T_Key, T_Value > & | next () const |
| Move to the next element and return the current element. | |
| const Pair< T_Key, T_Value > & | 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< Pair< T_Key, T_Value > > | |
| ClearQueue (ClearQueue const &)=delete | |
| Deleted copy constructor to prevent copying. | |
| ClearQueue () | |
| Constructs an empty queue. | |
| void | operator= (ClearQueue const &)=delete |
| Deleted assignment operator to prevent copying. | |
| virtual | ~ClearQueue () |
| Destroys the queue and releases all allocated memory. | |
| void | push (const Pair< T_Key, T_Value > &value) |
| Adds an element to the end of the queue. | |
| bool | pushUnique (const Pair< T_Key, T_Value > &value) |
| Adds an element to the queue only if it doesn't already exist. | |
| Pair< T_Key, T_Value > | hardPop () |
| Removes and returns the element at the front of the queue. | |
| const Pair< T_Key, T_Value > & | hardPeek () const |
| Returns the element at the front of the queue without removing it. | |
| Pair< T_Key, T_Value > | pop (const Pair< T_Key, T_Value > &errorCode) |
| Safely removes and returns the element at the front of the queue. | |
| const Pair< T_Key, T_Value > & | peek (const Pair< T_Key, T_Value > &errorCode) const |
| Safely returns the element at the front of the queue without removing it. | |
| bool | removeOne (const Pair< T_Key, T_Value > &value) |
| Removes the first occurrence of a specific value from the queue. | |
| bool | contains (const Pair< T_Key, T_Value > &value) const |
| Checks if the queue contains a specific value. | |
| Pair< T_Key, T_Value > * | find (const Pair< T_Key, T_Value > &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 | |
Protected Types inherited from ClearQueue< Pair< T_Key, T_Value > > | |
| typedef struct ClearQueue::node * | pnode |
| Node structure for the linked list implementation. | |
Protected Attributes inherited from IterableQueue< Pair< T_Key, T_Value > > | |
| ClearQueue< Pair< T_Key, T_Value > >::pnode | mCurrent |
| Pointer to the current node during iteration. | |
Protected Attributes inherited from ClearQueue< Pair< T_Key, T_Value > > | |
| pnode | mHead |
| Pointer to the first node in the queue. | |
| pnode | mTail |
| Pointer to the last node in the queue. | |
| using uniot::Map< T_Key, T_Value >::MapItem = Pair<T_Key, T_Value> |
Type alias for a key-value pair in the map.
|
inline |
Checks if a key exists in the map.
This method iterates through all key-value pairs in the map to determine if the specified key exists.
| key | The key to check for. |
| true | The key exists in the map. |
| false | The key does not exist in the map. |
|
inline |
Retrieves the value associated with a key.
This method iterates through the map to find the key. If found, it returns the associated value; otherwise, it returns the default value.
| key | The key to search for. |
| defaultValue | The default value to return if the key is not found. |
| value | The value associated with the key. |
| defaultValue | The default value if the key is not found. |
|
inline |
Inserts a key-value pair into the map.
This method checks if the key already exists in the map. If not, it adds a new key-value pair to the map.
| key | The key to insert. |
| value | The value to associate with the key. |
| true | Insertion was successful. |
| false | The key already exists in the map. |
|
inline |
Removes a key-value pair from the map.
This method searches for the specified key and removes the corresponding key-value pair if found.
| key | The key of the pair to remove. |
| true | The key-value pair was successfully removed. |
| false | The key was not found in the map. |