/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/HashFunc.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/HashFunc.hh Source File
Ratpac-two
HashFunc.hh
1 #ifndef __RAT_HashFunc__
2 #define __RAT_HashFunc__
3 
4 #include <string>
5 
6 namespace RAT {
7 
8 // String hashing algorithm taken from Python 2.4.1, stringobject.c
9 // Why doesn't STL include this stuff?!
10 struct pyhash {
11  unsigned operator()(const std::string &s) const {
12  int len;
13  int full_len;
14  unsigned char *p;
15  long x;
16 
17  full_len = len = s.size();
18  p = (unsigned char *)s.c_str();
19  x = *p << 7;
20  while (--len >= 0) x = (1000003 * x) ^ *p++;
21  x ^= full_len;
22  return x;
23  }
24 };
25 
26 } // namespace RAT
27 
28 #endif
Definition: CCCrossSecMessenger.hh:29
Definition: HashFunc.hh:10