|
| SCmnMap (void(*funOnKeyRemoved)(const TObj &)=NULL) |
| Constructor.
|
|
virtual | ~SCmnMap () |
| Destructor.
|
|
bool | HasKey (const TKey &key) const |
| Checks if a key exists in the map.
|
|
bool | GetKeyObject (const TKey &key, TObj &obj) const |
| Retrieves an object associated with a key.
|
|
TObj & | GetKeyObject (const TKey &key) const |
| Retrieves an object associated with a key.
|
|
bool | AddKeyObject (const TKey &key, const TObj &obj) |
| Adds a key-object pair to the map.
|
|
void | SetKeyObject (const TKey &key, const TObj &obj) |
| Sets an object for a key, replacing any existing object.
|
|
bool | RemoveKeyObject (const TKey &key) |
| Removes a key-object pair from the map.
|
|
void | RemoveAll () |
| Removes all key-object pairs from the map.
|
|
size_t | GetCount () |
| Gets the number of key-object pairs in the map.
|
|
template<class TObj, class TKey = SStringA>
class SCmnMap< TObj, TKey >
Template class for managing a map of objects with keys.
This template class provides a map-like structure to store and manage objects associated with keys. It includes methods for adding, retrieving, and removing objects, as well as handling key removal callbacks.
- Template Parameters
-
TObj | Type of the objects stored in the map |
TKey | Type of the keys used to identify objects (default is SStringA) |
Definition at line 20 of file SCmnMap.h.
template<class TObj, class TKey = SStringA>
bool SCmnMap< TObj, TKey >::AddKeyObject |
( |
const TKey & | key, |
|
|
const TObj & | obj ) |
|
inline |
Adds a key-object pair to the map.
- Parameters
-
key | Key to add |
obj | Object to associate with the key |
- Returns
- TRUE if the key was added successfully, otherwise FALSE
Adds a new key-object pair to the map. Returns FALSE if the key already exists.
Definition at line 94 of file SCmnMap.h.
template<class TObj, class TKey = SStringA>
TObj & SCmnMap< TObj, TKey >::GetKeyObject |
( |
const TKey & | key | ) |
const |
|
inline |
Retrieves an object associated with a key.
- Parameters
-
- Returns
- Reference to the object associated with the key
Returns a reference to the object associated with the specified key. Note: This method does not check if the key exists.
Definition at line 81 of file SCmnMap.h.
template<class TObj, class TKey = SStringA>
bool SCmnMap< TObj, TKey >::GetKeyObject |
( |
const TKey & | key, |
|
|
TObj & | obj ) const |
|
inline |
Retrieves an object associated with a key.
- Parameters
-
key | Key to look up |
obj | Object to store the retrieved value |
- Returns
- TRUE if the key exists and the object is retrieved, otherwise FALSE
Retrieves the object associated with the specified key and stores it in the provided object.
Definition at line 65 of file SCmnMap.h.
template<class TObj, class TKey = SStringA>
bool SCmnMap< TObj, TKey >::RemoveKeyObject |
( |
const TKey & | key | ) |
|
|
inline |
Removes a key-object pair from the map.
- Parameters
-
- Returns
- TRUE if the key was removed successfully, otherwise FALSE
Removes the key-object pair associated with the specified key. Calls the callback function if it is set.
Definition at line 123 of file SCmnMap.h.
template<class TObj, class TKey = SStringA>
void SCmnMap< TObj, TKey >::SetKeyObject |
( |
const TKey & | key, |
|
|
const TObj & | obj ) |
|
inline |
Sets an object for a key, replacing any existing object.
- Parameters
-
key | Key to set |
obj | Object to associate with the key |
Sets the object for the specified key, removing any existing object associated with the key.
Definition at line 109 of file SCmnMap.h.