#include <icy/collection.h>Subclassed by:
TimedManager< TKey, TValue >
A keyed store of unique_ptr values with optional lifecycle hooks. Not thread-safe; designed for single-threaded event loop contexts.
Subclasses can override onAdd/onRemove for lifecycle reactions, and add Signal members for external observers.
| Return | Name | Description |
|---|---|---|
KeyedStore | Defaulted constructor. | |
KeyedStore | Deleted constructor. | |
KeyedStore | Defaulted constructor. | |
TValue * | get const inline | Returns the item for key, or nullptr if not found. |
TValue & | add inline | Inserts a uniquely owned item. Returns a reference to the stored item. |
bool | tryAdd inline | Inserts if absent; returns false on duplicate (never throws). |
TValue & | put inline | Inserts or replaces the item under key. |
bool | erase inline | Removes and destroys the item under key. |
bool | contains const inline | |
bool | empty const inline | |
size_t | size const inline | |
void | clear inline | |
Map & | map inline | Direct map access for iteration. |
const Map & | map const inline | |
auto | begin inline | |
auto | end inline | |
auto | begin const inline | |
auto | end const inline |
KeyedStore() = defaultDefaulted constructor.
KeyedStore(constKeyedStore &) = deleteDeleted constructor.
KeyedStore(KeyedStore &&) = defaultDefaulted constructor.
const inline
inline TValue * get(constTKey & key) constReturns the item for key, or nullptr if not found.
inline
inline TValue & add(constTKey & key, std::unique_ptr< TValue > item)Inserts a uniquely owned item. Returns a reference to the stored item.
std::runtime_error if the key already exists.inline
inline bool tryAdd(constTKey & key, std::unique_ptr< TValue > item)Inserts if absent; returns false on duplicate (never throws).
inline
inline TValue & put(constTKey & key, std::unique_ptr< TValue > item)Inserts or replaces the item under key.
inline
inline bool erase(constTKey & key)Removes and destroys the item under key.
true if the item existed and was removed.
const inline
inline bool contains(constTKey & key) constconst inline
inline bool empty() constconst inline
inline size_t size() constinline
inline void clear()inline
inline Map & map()Direct map access for iteration.
const inline
inline const Map & map() constinline
inline auto begin()inline
inline auto end()const inline
inline auto begin() constconst inline
inline auto end() const| Return | Name | Description |
|---|---|---|
Map | _map |
Map _map| Return | Name | Description |
|---|---|---|
void | onAdd virtual inline | Override for lifecycle reactions. |
void | onRemove virtual inline |
virtual inline
virtual inline void onAdd(constTKey &, TValue *)Override for lifecycle reactions.
virtual inline
virtual inline void onRemove(constTKey &, TValue *)| Name | Description |
|---|---|
Map |
std::map< TKey, std::unique_ptr< TValue > > Map()