comparison fastx_toolkit-0.0.6/src/fastx_collapser/std_hash.h @ 3:997f5136985f draft default tip

Uploaded
author xilinxu
date Thu, 14 Aug 2014 04:52:17 -0400
parents
children
comparison
equal deleted inserted replaced
2:dfe9332138cf 3:997f5136985f
1 /*
2 FASTX-toolkit - FASTA/FASTQ preprocessing tools.
3 Copyright (C) 2009 A. Gordon (gordon@cshl.edu)
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Affero General Public License as
7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef __STD_HASH__
19 #define __STD_HASH__
20
21
22 /*
23 * Centralized place to load std::hash_map
24 *
25 * GCC needs the following hacks...
26 * Other compilers/systems might require different hacks
27 */
28
29 #include <ext/hash_map>
30 #include <ext/hash_set>
31
32 namespace std
33 {
34 using namespace __gnu_cxx;
35
36 struct std_string_hash
37 {
38 size_t operator()( const std::string& x ) const
39 {
40 //printf("std_string_hash: hashing '%s'\n", x.c_str());
41 return hash< const char* >()( x.c_str() );
42 }
43 };
44
45 /*
46 * 'eqstr' and 'hash_map' usage is based on http://www.sgi.com/tech/stl/hash_map.html
47 */
48 struct eqstr
49 {
50 bool operator()(const char* s1, const char* s2) const
51 {
52 return strcmp(s1, s2) == 0;
53 }
54 };
55
56 typedef hash_map< const char*, int, hash< const char* >, eqstr > hash_map_charptr_to_int;
57
58 typedef hash_map< string, int, std_string_hash > hash_map_string_to_int;
59
60 typedef hash_set < string, std_string_hash > hash_set_string ;
61 }
62
63 #endif
64