1 #pragma once
2 // Description:
3 // Template to find the matching value for a given key in a hash map.
4 //
5 // Copyright (C) 2005 Frank Becker
6 //
7 // This program is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU General Public License as published by the Free Software
9 // Foundation; either version 2 of the License, or (at your option) any later
10 // version.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
15 //
16 #include "hashMap.hpp"
17
18 template< class _KeyT, class _ValT >
findHash(_KeyT & trigger,hash_map<_KeyT,_ValT *,hash<_KeyT>,std::equal_to<_KeyT>> & hashMap)19 _ValT* findHash(
20 _KeyT &trigger,
21 hash_map< _KeyT, _ValT*, hash<_KeyT>, std::equal_to<_KeyT> > & hashMap )
22 {
23 typename hash_map< _KeyT, _ValT*, hash<_KeyT> >::const_iterator ci;
24 ci = hashMap.find( trigger);
25 if( ci == hashMap.end())
26 {
27 return 0;
28 }
29
30 return ci->second;
31 }
32
33 #ifdef VCPP
34 template< class _KeyT, class _ValT >
findHash(const _KeyT & trigger,hash_map<_KeyT,_ValT *,hash<_KeyT>,std::equal_to<_KeyT>> & hashMap)35 _ValT* findHash(
36 const _KeyT &trigger,
37 hash_map< _KeyT, _ValT*, hash<_KeyT>, std::equal_to<_KeyT> > & hashMap )
38 {
39 typename hash_map< const _KeyT, _ValT*, hash<const _KeyT> >::const_iterator ci;
40 ci = hashMap.find( trigger);
41 if( ci == hashMap.end())
42 {
43 return 0;
44 }
45
46 return ci->second;
47 }
48 #endif
49