monotone

monotone Mtn Source Tree

Root/hash_map.hh

1#ifndef __HASHMAP_HH
2#define __HASHMAP_HH
3
4#include <config.h>
5
6#ifdef HAVE_GNUCXX_HASHMAP
7#define HASHMAP_PRESENT
8#include <ext/hash_map>
9#include <string>
10
11namespace hashmap {
12 using __gnu_cxx::hash_map;
13
14 struct string_hash
15 {
16 size_t operator()(std::string const & s) const
17 {
18 return __gnu_cxx::__stl_hash_string(s.c_str());
19 }
20 };
21
22
23}
24#endif
25
26#ifdef HAVE_STLPORT_HASHMAP
27#define HASHMAP_PRESENT
28#include <hash_map>
29#include <string>
30
31namespace hashmap {
32 using std::hash_map;
33
34 struct string_hash
35 {
36 size_t operator()(std::string const & s) const
37 {
38 const char* s2=s.c_str();
39 unsigned long h = 0;
40 for ( ; *s2; ++s2)
41 h = 5*h + *s2;
42 return size_t(h);
43 }
44 };
45}
46#endif
47
48#ifndef HASHMAP_PRESENT
49#error need wrapper for hash_map for your compiler
50#endif
51
52#undef HASHMAP_PRESENT
53
54#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status