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