Extension of the STL map.
More...
#include <Map.h>
List of all members.
Public Types |
| typedef M | map_type |
| typedef K | key_type |
| typedef T | mapped_type |
| typedef K | argument_type |
| typedef T | result_type |
| typedef std::pair< const K, T > | value_type |
| typedef map_type::size_type | size_type |
| typedef map_type::iterator | iterator |
| typedef map_type::const_iterator | const_iterator |
Public Member Functions |
| | Map () |
| | Standard constructor.
|
| | Map (const map_type &other) |
| | Constructor from a standard map.
|
| template<typename In > |
| | Map (In first, In last) |
| | Construct from a subset.
|
| virtual | ~Map () |
| | Virtual destructor. You can inherit from this map type.
|
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| mapped_type & | operator[] (const key_type &key) |
| iterator | find (const key_type &key) |
| const_iterator | find (const key_type &key) const |
| size_type | count (const key_type &key) const |
| iterator | lower_bound (const key_type &key) |
| const_iterator | lower_bound (const key_type &key) const |
| iterator | upper_bound (const key_type &key) |
| const_iterator | upper_bound (const key_type &key) const |
| std::pair< iterator, iterator > | equal_range (const key_type &key) |
std::pair< const_iterator,
const_iterator > | equal_range (const key_type &key) const |
| std::pair< iterator, bool > | insert (const value_type &val) |
| std::pair< iterator, bool > | insert (const key_type &key, const mapped_type &val) |
| template<typename In > |
| void | insert (In first, In last) |
| iterator | insert (iterator, const value_type &val) |
| void | erase (iterator pos) |
| size_type | erase (const key_type &key) |
| void | erase (iterator first, iterator last) |
| void | clear () |
| size_type | size () const |
| size_type | max_size () const |
| bool | empty () const |
| void | swap (map_type &other) |
| const result_type & | operator() (const argument_type &key) const |
| | Allow to use Map as an unary function.
|
| const mapped_type & | operator[] (const key_type &key) const |
| | Access elements of a const Map.
|
| const result_type & | at (const argument_type &key) const |
| | checked access to the map
- Exceptions:
-
|
| Map & | merge (const map_type &other) |
| | Merge two maps.
|
| Map & | merge (const Map &other) |
| | Merge two maps.
|
| template<class K1 , class K2 , class K3 > |
| Map & | merge (const Map< K1, K2, K3 > &other) |
| | Merge two maps.
|
| void | update (const key_type &key, const mapped_type &mapped) |
| | operator map_type & () |
| | Allows to use the Map wherever an std::map is explicitly requested.
|
| | operator const map_type & () const |
| const key_type & | key_at (const size_type index) const |
| | useful method for python decoration:
|
| const mapped_type & | value_at (const size_type index) const |
| | useful method for python decoration:
|
Protected Attributes |
| map_type | m_map |
Static Protected Attributes |
| static const result_type | s_null_value = typename Map<K,T,M>::result_type() |
Detailed Description
template<typename K, typename T, typename M = std::map<K,T>>
class GaudiUtils::Map< K, T, M >
Extension of the STL map.
Provides const accessors and can be extended by inheritance.
- See also:
- std::map Note: in order to make it possible to use either a map or a hash_map, reverse iterators are not defined.
Due to helper base class Gaudi::Utils::MapBase, this class is "python-friendly", and one can perform all python manipulaitons in intuitive way:
>>> m = ... ## get the map
>>> print m ## print the map a'la python class dict
...
>>> for key in m : print key, m[key] ## iteration over the map
...
>>> for key,value in m.iteritems() : print key, value
...
>>> keys = m.keys() ## get the list of keys
>>> values = m.values () ## get the list of values
>> items = m.items () ## get the list of items
>>> if 'one' in m ## check the presence of the key in map
>>> v = m.get(key', None) ## return m[key] for existing key, else None
>>> del m[key] ## erase the key form the map
>>> value m[key] ## unchecked access through the key
...
>>> m.update( key, value ) ## update/insert key/value pair
- Attention:
- The syntax can be drastically simplified, if one redefines the __setitem__ attribute:
>>> type(m).__setitem__ = Gaudi.Utils.MapBase.__setitem__
>>> m[key] = value ## much more intuitive semantics for key insertion
In a similar way __getitem__ and __delitem__ methods can be redefined.
- Attention:
- To avoid the unnesessary expansion of dictionaries it is recommended to exclude from dictionary the following methods:
- lower_bound
- upper_bound
- equal_range
- insert
- Warning:
- This action is required for
HashMap to avodi the compilation problems
- See also:
- Gaudi::Utils::MapBase
- Author:
- Marco Clemencic
- Date:
- 2005-10-06
Definition at line 82 of file Map.h.
Member Typedef Documentation
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 92 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 99 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 98 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 88 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 87 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 89 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 93 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 96 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 94 of file Map.h.
Constructor & Destructor Documentation
template<typename K, typename T, typename M = std::map<K,T>>
Standard constructor.
Definition at line 112 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Constructor from a standard map.
Definition at line 115 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
template<typename In >
Construct from a subset.
Definition at line 121 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Virtual destructor. You can inherit from this map type.
Definition at line 124 of file Map.h.
Member Function Documentation
template<typename K, typename T, typename M = std::map<K,T>>
checked access to the map
- Exceptions:
-
- Parameters:
-
- Returns:
- the value for the existing key
Definition at line 248 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 151 of file Map.h.
{ return m_map.count(key); }
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 158 of file Map.h.
{ return m_map.equal_range(key); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 160 of file Map.h.
{ return m_map.equal_range(key); }
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 175 of file Map.h.
{ m_map.erase(first,last); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 174 of file Map.h.
{ return m_map.erase(key); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 148 of file Map.h.
{ return m_map.find(key); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 149 of file Map.h.
{ return m_map.find(key); }
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename In >
Definition at line 170 of file Map.h.
{ m_map.insert(first,last); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 171 of file Map.h.
{ return m_map.insert( val ).first ; }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 165 of file Map.h.
{ return m_map.insert(val); }
template<typename K, typename T, typename M = std::map<K,T>>
useful method for python decoration:
- Parameters:
-
- Returns:
- the key at given index
- Exceptions:
-
Definition at line 295 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 154 of file Map.h.
{ return m_map.lower_bound(key); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 153 of file Map.h.
{ return m_map.lower_bound(key); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 181 of file Map.h.
{ return m_map.max_size(); }
template<typename K, typename T, typename M = std::map<K,T>>
template<class K1 , class K2 , class K3 >
Merge two maps.
Definition at line 271 of file Map.h.
{
for ( typename Map<K1,K2,K3>::const_iterator it = other.begin() ;
other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
return *this;
}
template<typename K, typename T, typename M = std::map<K,T>>
Merge two maps.
Definition at line 263 of file Map.h.
{
for ( const_iterator it = other.begin() ;
other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
return *this;
}
template<typename K, typename T, typename M = std::map<K,T>>
Merge two maps.
Definition at line 256 of file Map.h.
{
for ( typename map_type::const_iterator it = other.begin() ;
other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
return *this;
}
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
Allows to use the Map wherever an std::map is explicitly requested.
Definition at line 285 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Allow to use Map as an unary function.
There is no automatic extension of the map for missing keys!
- Attention:
- The behaviour is different from std::map
- Parameters:
-
- Returns:
- the mapped value(const reference!) for the existing key, and the default value overwise
return the default value
Definition at line 209 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
Access elements of a const Map.
There is no automatic extension of the map for missing keys!
- Attention:
- The behaviour is different from std::map
- Parameters:
-
- Returns:
- the mapped value(const reference!) for the existing key, and the default value overwise
Definition at line 240 of file Map.h.
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 279 of file Map.h.
{ (*this)[ key ] = mapped ; }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 156 of file Map.h.
{ return m_map.upper_bound(key); }
template<typename K, typename T, typename M = std::map<K,T>>
Definition at line 155 of file Map.h.
{ return m_map.upper_bound(key); }
template<typename K, typename T, typename M = std::map<K,T>>
useful method for python decoration:
- Parameters:
-
- Returns:
- the value at given index
- Exceptions:
-
Definition at line 308 of file Map.h.
Member Data Documentation
template<typename K, typename T, typename M = std::map<K,T>>
template<typename K, typename T, typename M = std::map<K,T>>
The documentation for this class was generated from the following file:
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r2/GaudiKernel/GaudiKernel/Map.h