| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Types | Public Member Functions

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

Common class providing an architecture-independent hash map. More...

`#include <GaudiKernel/HashMap.h>`

Inheritance diagram for GaudiUtils::HashMap< K, T, H, M >:
[legend]
Collaboration diagram for GaudiUtils::HashMap< K, T, H, M >:
[legend]

List of all members.

## Public Types
typedef H | hasher
## Public Member Functions
hasher | hash_funct () const

## Detailed Description

### template<typename K, typename T, typename H = Hash<K>, typename M = __gnu_cxx::hash_map<K,T,H>>
class GaudiUtils::HashMap< K, T, H, M >

Common class providing an architecture-independent hash map.

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:
  One needs to redfine `__setitem__` and `__getitem__` methods in python:

        >>> type(m).__setitem__ = Gaudi.Utils.MapBase.__setitem__
        >>> type(m).__getitem__ = Gaudi.Utils.MapBase.__getitem__

        >>> m[key] = value  ## much more intuitive semantics for key insertion

In a similar way `__delitem__` methods can be redefined.

Warning:
  To bypass some compilation problme (and to avoid the unnesessary expansion of dictionaries) it is nesessary to exclude from dictionary the following methods:
  - lower_bound
  - upper_bound
  - equal_range
  - insert

See also:
  Gaudi::Utils::MapBase

Author:
  Marco Clemencic

Date:
  2005-10-06

Definition at line 108 of file HashMap.h.

## Member Typedef Documentation

template<typename K, typename T, typename H = Hash<K>, typename M = __gnu_cxx::hash_map<K,T,H>>

typedef H GaudiUtils::HashMap< K, T, H, M >::hasher

Definition at line 111 of file HashMap.h.

## Member Function Documentation

template<typename K, typename T, typename H = Hash<K>, typename M = __gnu_cxx::hash_map<K,T,H>>

hasher GaudiUtils::HashMap< K, T, H, M >::hash_funct | ( | ) | const`[inline]`

Definition at line 113 of file HashMap.h.

                                         {
    // Marco Cl.: since on windows we are using a std::map, we have to provide a different implementation
    // for GaudiUtils::HashMap::hash_funct(). (std::map::hash_funct does not exist)
    #ifdef _WIN32
          return hasher();
    #else
          return this->m_map.hash_funct();
    #endif
        }

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiKernel/GaudiKernel/HashMap.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines