MapUtilities Class Reference

Provides some utility functions to deal with std::map. More...

List of all members.

Static Public Member Functions

template<typename MapT >
static AutoPtr< typename
RemovePointer< typename
MapT::mapped_type >::type > 
InsertOrUpdate (MapT &in_map, const typename MapT::key_type &in_key, typename MapT::mapped_type in_value)
 Inserts or updates a value into a map which OWNs its values (they must be pointers).
template<typename MapT >
static AutoPtr< typename
RemovePointer< typename
MapT::mapped_type >::type > 
InsertOrUpdate (MapT &in_map, const typename MapT::key_type &in_key, AutoPtr< typename RemovePointer< typename MapT::mapped_type >::type > in_value)
 Inserts or updates a value into a map which OWNs its values (they must be pointers).
template<typename MapT >
static AutoPtr< typename
RemovePointer< typename
MapT::mapped_type >::type > 
Remove (MapT &in_map, typename MapT::iterator in_iterator)
 Removes a value into a map which OWNs its values (they must be pointers).

Detailed Description

Provides some utility functions to deal with std::map.


Member Function Documentation

static AutoPtr<typename RemovePointer<typename MapT::mapped_type>::type> InsertOrUpdate ( MapT &  in_map,
const typename MapT::key_type &  in_key,
typename MapT::mapped_type  in_value 
) [inline, static]

Inserts or updates a value into a map which OWNs its values (they must be pointers).

Parameters:
MapT The map type. Should be std::map<K, V*> for some K and V (or interface-compatible).
in_map The map to modify. It should OWN its values (but not its keys).
in_key The key for which to insert or update. If the given map already contains an entry for the given key, the current value for that key will be replaced with in_value. Otherwise <in_key, in_value> will simply be put into the map.
in_value The value to put into the given map for the given key. (OWN).

Note: One advantage of this function is that it uses a hint for insertion from the original search, instead of searching the map twice (once to check if the key is already in the map, and once to insert it if not).

Returns:
The old value in the map for the given key if there was one, or a NULL AutoPtr otherwise.
static AutoPtr<typename RemovePointer<typename MapT::mapped_type>::type> InsertOrUpdate ( MapT &  in_map,
const typename MapT::key_type &  in_key,
AutoPtr< typename RemovePointer< typename MapT::mapped_type >::type >  in_value 
) [inline, static]

Inserts or updates a value into a map which OWNs its values (they must be pointers).

Parameters:
MapT The map type. Should be std::map<K, V*> for some K and V (or interface-compatible).
in_map The map to modify. It should OWN its values (but not its keys).
in_key The key for which to insert or update. If the given map already contains an entry for the given key, the current value for that key will be replaced with in_value. Otherwise <in_key, in_value> will simply be put into the map.
in_value The value to put into the given map for the given key.

Note: One advantage of this function is that it uses a hint for insertion from the original search, instead of searching the map twice (once to check if the key is already in the map, and once to insert it if not).

Returns:
The old value in the map for the given key if there was one, or a NULL AutoPtr otherwise.
static AutoPtr<typename RemovePointer<typename MapT::mapped_type>::type> Remove ( MapT &  in_map,
typename MapT::iterator  in_iterator 
) [inline, static]

Removes a value into a map which OWNs its values (they must be pointers).

Parameters:
MapT The map type. Should be std::map<K, V*> for some K and V (or interface-compatible).
in_map The map to modify. It should OWN its values (but not its keys).
in_iterator The iterator to remove from the map.
Returns:
The old value in the map for the given iterator.

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

Generated on Wed May 17 14:21:19 2017 for SimbaEngine 10.1.3.1011 by simba