Commit 6f2225b3 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

use std::unordered_map for the implementation of GaudiUtils::HashMap

parent b88d3e60
// $Id: HashMap.h,v 1.7 2008/11/01 14:30:21 marcocle Exp $
#ifndef GAUDIKERNEL_HASHMAP_H
#define GAUDIKERNEL_HASHMAP_H 1
......@@ -11,75 +10,72 @@
#elif defined(__ICC)
// icc uses the headers from GCC...
#include <ext/hash_map>
#elif __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 3 )
#elif __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 5 )
#include <ext/hash_map>
#elif __GNUC__ >= 4
// Marco Cl.: in gcc >= 4.3 the hash_map has been replaced by unordered_map
//#include <tr1/unordered_map>
// but gccxml has problems with it
#include <ext/hash_map>
#include <unordered_map>
#endif
namespace GaudiUtils
namespace GaudiUtils
{
// ==========================================================================
/** @class HashMap HashMap.h GaudiKernel/HashMap.h
*
* 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
*
* Due to helper base class Gaudi::Utils::MapBase, this class
* is "python-friendly", and one can perform all python
* manipulations
* in intuitive way:
* @code
*
* >>> m = ... ## get the map
* >>> print m ## print the map a'la python class dict
* ...
* @code
*
* >>> 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
* >>> 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
* >>> 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
* >>> 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
*
* @endcode
*
* @attention One needs to redfine <c>__setitem__</c> and <c>__getitem__</c>
* >>> m.update( key, value ) ## update/insert key/value pair
*
* @endcode
*
* @attention One needs to redefine <c>__setitem__</c> and <c>__getitem__</c>
* methods in python:
*
* @code
*
* >>> type(m).__setitem__ = Gaudi.Utils.MapBase.__setitem__
* >>> type(m).__getitem__ = Gaudi.Utils.MapBase.__getitem__
* @code
*
* >>> type(m).__setitem__ = Gaudi.Utils.MapBase.__setitem__
* >>> type(m).__getitem__ = Gaudi.Utils.MapBase.__getitem__
*
* >>> m[key] = value ## much more intuitive semantics for key insertion
*
* @endcode
* @endcode
* In a similar way <c>__delitem__</c> methods can be redefined.
* @warning
* To bypass some compilation problme (and to avoid the unnesessary
* expansion of dictionaries) it is nesessary to exclude from
* To bypass some compilation problem (and to avoid the unnecessary
* expansion of dictionaries) it is necessary to exclude from
* dictionary the following methods:
* - lower_bound
* - upper_bound
* - equal_range
* - insert
*
* @see Gaudi::Utils::MapBase
*
* - lower_bound
* - upper_bound
* - equal_range
* - insert
*
* @see Gaudi::Utils::MapBase
*
* @author Marco Clemencic
* @date 2005-10-06
*/
......@@ -96,13 +92,10 @@ namespace GaudiUtils
#elif defined(__ICC)
// icc uses the headers from GCC...
typename M = __gnu_cxx::hash_map<K,T,H>
#elif __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 3 )
#elif __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 5 )
typename M = __gnu_cxx::hash_map<K,T,H>
#elif __GNUC__ >= 4
// Marco Cl.: in gcc >= 4.3 the hash_map has been replaced by unordered_map
// typename M = std::tr1::unordered_map<K,T,H>
typename M = __gnu_cxx::hash_map<K,T,H>
// but gccxml has problems with it
typename M = std::unordered_map<K,T,H>
#endif
>
class HashMap: public Map<K,T,M> {
......
Package : GaudiKernel
Package manager : Marco Clemencic
! 2011-10-28 - Marco Clemencic
- Use unordered_map as internal implementation of GaudiUtils::HashMap from
gcc 4.5 on (requires C++0x).
! 2011-10-27 - Marco Clemencic
- Introduced the function System::getProcessTime(pid), the helper class
ProcessTime and a templated version of adjustTime in GaudiKernel/Timing.h
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment