CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
string_hash.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: string hashing
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
11
12#include "string_hash.h"
13
14size_t hash_string(const std::string &s)
15{
16 size_t h=0;
17 size_t size=s.size();
18
19 for(unsigned i=0; i<size; i++)
20 h=(h<<5)-h+s[i];
21
22 return h;
23}
24
25size_t hash_string(const char *s)
26{
27 size_t h=0;
28
29 for(; *s!=0; s++)
30 h=(h<<5)-h+*s;
31
32 return h;
33}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
size_t hash_string(const std::string &s)
string hashing