| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# GaudiUtils::Map< K, T, M > Class Template Reference

Extension of the STL map. More...

`#include <GaudiKernel/Map.h>`

Inheritance diagram for GaudiUtils::Map< K, T, M >:

[legend]
Collaboration diagram for GaudiUtils::Map< K, T, M >:

[legend]

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)
iterator | insert (iterator pos, const value_type &val)
template<typename In>
void | insert (In first, In last)
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.
Map & | merge (const map_type &other)
| Merge two maps.
| operator map_type & ()
| Allows to use the Map wherever an std::map is explicitly requested.
| operator const map_type & () const
## 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.

Author:
  Marco Clemencic

Date:
  2005-10-06

Definition at line 30 of file Map.h.

## Member Typedef Documentation

template<typename K, typename T, typename M = std::map<K,T>>

typedef M GaudiUtils::Map< K, T, M >::map_type

Definition at line 35 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef K GaudiUtils::Map< K, T, M >::key_type

Definition at line 36 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef T GaudiUtils::Map< K, T, M >::mapped_type

Definition at line 37 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef K GaudiUtils::Map< K, T, M >::argument_type

Definition at line 40 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef T GaudiUtils::Map< K, T, M >::result_type

Definition at line 41 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef std::pair<const K,T> GaudiUtils::Map< K, T, M >::value_type

Definition at line 42 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef map_type::size_type GaudiUtils::Map< K, T, M >::size_type

Definition at line 44 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef map_type::iterator GaudiUtils::Map< K, T, M >::iterator

Definition at line 46 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

typedef map_type::const_iterator GaudiUtils::Map< K, T, M >::const_iterator

Definition at line 47 of file Map.h.

## Constructor & Destructor Documentation

template<typename K, typename T, typename M = std::map<K,T>>

GaudiUtils::Map< K, T, M >::Map | ( |  | ) | `[inline]`

Standard constructor.

Definition at line 60 of file Map.h.

    00060 : m_map() {}

template<typename K, typename T, typename M = std::map<K,T>>

GaudiUtils::Map< K, T, M >::Map | ( | const map_type & | other | ) | `[inline]`

Constructor from a standard map.

Definition at line 63 of file Map.h.

    00063 : m_map(other) {}

template<typename K, typename T, typename M = std::map<K,T>>
template<typename In>

GaudiUtils::Map< K, T, M >::Map | ( | In | first,
|  | In | last |
| ) |  |  | `[inline]`

Construct from a subset.

Definition at line 69 of file Map.h.

    00069 : m_map(first,last) {}

template<typename K, typename T, typename M = std::map<K,T>>

virtual GaudiUtils::Map< K, T, M >::~Map | ( |  | ) | `[inline, virtual]`

Virtual destructor. You can inherit from this map type.

Definition at line 72 of file Map.h.

    00072 {}

## Member Function Documentation

template<typename K, typename T, typename M = std::map<K,T>>

iterator GaudiUtils::Map< K, T, M >::begin | ( | void |  | ) | `[inline]`

Definition at line 78 of file Map.h.

    00078 { return m_map.begin(); }

template<typename K, typename T, typename M = std::map<K,T>>

iterator GaudiUtils::Map< K, T, M >::end | ( | void |  | ) | `[inline]`

Definition at line 79 of file Map.h.

    00079 { return m_map.end(); }

template<typename K, typename T, typename M = std::map<K,T>>

const_iterator GaudiUtils::Map< K, T, M >::begin | ( | void |  | ) | const`[inline]`

Definition at line 81 of file Map.h.

    00081 { return m_map.begin(); }

template<typename K, typename T, typename M = std::map<K,T>>

const_iterator GaudiUtils::Map< K, T, M >::end | ( | void |  | ) | const`[inline]`

Definition at line 82 of file Map.h.

    00082 { return m_map.end(); }

template<typename K, typename T, typename M = std::map<K,T>>

mapped_type& GaudiUtils::Map< K, T, M >::operator[] | ( | const key_type & | key | ) | `[inline]`

Definition at line 92 of file Map.h.

    00092 { return m_map[key]; }

template<typename K, typename T, typename M = std::map<K,T>>

iterator GaudiUtils::Map< K, T, M >::find | ( | const key_type & | key | ) | `[inline]`

Definition at line 96 of file Map.h.

    00096 { return m_map.find(key); }

template<typename K, typename T, typename M = std::map<K,T>>

const_iterator GaudiUtils::Map< K, T, M >::find | ( | const key_type & | key | ) | const`[inline]`

Definition at line 97 of file Map.h.

    00097 { return m_map.find(key); }

template<typename K, typename T, typename M = std::map<K,T>>

size_type GaudiUtils::Map< K, T, M >::count | ( | const key_type & | key | ) | const`[inline]`

Definition at line 99 of file Map.h.

    00099 { return m_map.count(key); }

template<typename K, typename T, typename M = std::map<K,T>>

iterator GaudiUtils::Map< K, T, M >::lower_bound | ( | const key_type & | key | ) | `[inline]`

Definition at line 101 of file Map.h.

    00101 { return m_map.lower_bound(key); }

template<typename K, typename T, typename M = std::map<K,T>>

const_iterator GaudiUtils::Map< K, T, M >::lower_bound | ( | const key_type & | key | ) | const`[inline]`

Definition at line 102 of file Map.h.

    00102 { return m_map.lower_bound(key); }

template<typename K, typename T, typename M = std::map<K,T>>

iterator GaudiUtils::Map< K, T, M >::upper_bound | ( | const key_type & | key | ) | `[inline]`

Definition at line 103 of file Map.h.

    00103 { return m_map.upper_bound(key); }

template<typename K, typename T, typename M = std::map<K,T>>

const_iterator GaudiUtils::Map< K, T, M >::upper_bound | ( | const key_type & | key | ) | const`[inline]`

Definition at line 104 of file Map.h.

    00104 { return m_map.upper_bound(key); }

template<typename K, typename T, typename M = std::map<K,T>>

std::pair<iterator,iterator> GaudiUtils::Map< K, T, M >::equal_range | ( | const key_type & | key | ) | `[inline]`

Definition at line 106 of file Map.h.

    00107     { return m_map.equal_range(key); }

template<typename K, typename T, typename M = std::map<K,T>>

std::pair<const_iterator,const_iterator> GaudiUtils::Map< K, T, M >::equal_range | ( | const key_type & | key | ) | const`[inline]`

Definition at line 108 of file Map.h.

    00109     { return m_map.equal_range(key); }

template<typename K, typename T, typename M = std::map<K,T>>

std::pair<iterator,bool> GaudiUtils::Map< K, T, M >::insert | ( | const value_type & | val | ) | `[inline]`

Definition at line 113 of file Map.h.

    00113 { return m_map.insert(val); }

template<typename K, typename T, typename M = std::map<K,T>>

iterator GaudiUtils::Map< K, T, M >::insert | ( | iterator | pos,
|  | const value_type & | val |
| ) |  |  | `[inline]`

Definition at line 114 of file Map.h.

    00114 { return m_map.insert(pos,val); }

template<typename K, typename T, typename M = std::map<K,T>>
template<typename In>

void GaudiUtils::Map< K, T, M >::insert | ( | In | first,
|  | In | last |
| ) |  |  | `[inline]`

Definition at line 116 of file Map.h.

    00116 { m_map.insert(first,last); }

template<typename K, typename T, typename M = std::map<K,T>>

void GaudiUtils::Map< K, T, M >::erase | ( | iterator | pos | ) | `[inline]`

Definition at line 118 of file Map.h.

    00118 { m_map.erase(pos); }

template<typename K, typename T, typename M = std::map<K,T>>

size_type GaudiUtils::Map< K, T, M >::erase | ( | const key_type & | key | ) | `[inline]`

Definition at line 119 of file Map.h.

    00119 { return m_map.erase(key); }

template<typename K, typename T, typename M = std::map<K,T>>

void GaudiUtils::Map< K, T, M >::erase | ( | iterator | first,
|  | iterator | last |
| ) |  |  | `[inline]`

Definition at line 120 of file Map.h.

    00120 { m_map.erase(first,last); }

template<typename K, typename T, typename M = std::map<K,T>>

void GaudiUtils::Map< K, T, M >::clear | ( | void |  | ) | `[inline]`

Definition at line 121 of file Map.h.

    00121 { m_map.clear(); }

template<typename K, typename T, typename M = std::map<K,T>>

size_type GaudiUtils::Map< K, T, M >::size | ( | void |  | ) | const`[inline]`

Definition at line 125 of file Map.h.

    00125 { return m_map.size(); }

template<typename K, typename T, typename M = std::map<K,T>>

size_type GaudiUtils::Map< K, T, M >::max_size | ( |  | ) | const`[inline]`

Definition at line 126 of file Map.h.

    00126 { return m_map.max_size(); }

template<typename K, typename T, typename M = std::map<K,T>>

bool GaudiUtils::Map< K, T, M >::empty | ( | void |  | ) | const`[inline]`

Definition at line 127 of file Map.h.

    00127 { return size() == 0; }

template<typename K, typename T, typename M = std::map<K,T>>

void GaudiUtils::Map< K, T, M >::swap | ( | map_type & | other | ) | `[inline]`

Definition at line 128 of file Map.h.

    00128 { m_map.swap(other); }

template<typename K, typename T, typename M = std::map<K,T>>

const result_type& GaudiUtils::Map< K, T, M >::operator() | ( | const argument_type & | key | ) | const`[inline]`

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

       const GaudiUtils::Map<KEY,VALUE> m = ... ;

       // OK:
       KEY key = ... ;
       std::cout << " Value: " << m(key) << std::end ; // it is OK!

       // ERROR:
       VALUE value = ... ;
       m(key) = value ;                                // ERROR!

Parameters:

  | key | the key

Returns:
  the mapped value(const reference!) for the existing key, and the default value overwise

< return the default value

Definition at line 154 of file Map.h.

    00155     {
    00156       // static const result_type s_null_value;
    00157       const_iterator it = m_map.find(key);
    00158       if ( it != m_map.end() ) { return it->second ; }
    00159       // return the default value
    00160       return s_null_value;
    00161     }

template<typename K, typename T, typename M = std::map<K,T>>

const mapped_type& GaudiUtils::Map< K, T, M >::operator[] | ( | const key_type & | key | ) | const`[inline]`

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

       const GaudiUtils::Map<KEY,VALUE> m = ... ;

       // OK:
       KEY key = ... ;
       std::cout << " Value: " << m[key] << std::end ; // it is OK!

       // ERROR:
       VALUE value = ... ;
       m[key] = value ;                                // ERROR!

Parameters:

  | key | the key

Returns:
  the mapped value(const reference!) for the existing key, and the default value overwise

Definition at line 185 of file Map.h.

    00186     { return (*this)(key); }

template<typename K, typename T, typename M = std::map<K,T>>

Map& GaudiUtils::Map< K, T, M >::merge | ( | const map_type & | other | ) | `[inline]`

Merge two maps.

Definition at line 189 of file Map.h.

    00190     {
    00191       for ( typename map_type::const_iterator it = other.begin() ;
    00192             other.end() != it ; ++it ) { (*this)[it->first] = it->second ; }
    00193       return *this;
    00194     }

template<typename K, typename T, typename M = std::map<K,T>>

GaudiUtils::Map< K, T, M >::operator map_type & | ( |  | ) | `[inline]`

Allows to use the Map wherever an std::map is explicitly requested.

Definition at line 197 of file Map.h.

    00197 { return m_map ; }

template<typename K, typename T, typename M = std::map<K,T>>

GaudiUtils::Map< K, T, M >::operator const map_type & | ( |  | ) | const`[inline]`

Definition at line 198 of file Map.h.

    00198 { return m_map ; }

## Member Data Documentation

template<typename K, typename T, typename M = std::map<K,T>>

map_type GaudiUtils::Map< K, T, M >::m_map`[protected]`

Definition at line 53 of file Map.h.

template<typename K, typename T, typename M = std::map<K,T>>

const Map< K, T, M >::result_type GaudiUtils::Map< K, T, M >::s_null_value = typename Map<K,T,M>::result_type()`[inline, static, protected]`

Definition at line 54 of file Map.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiKernel/GaudiKernel/Map.h