ZGen  0.2.0
a linearization system for natural language.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hasher.h
Go to the documentation of this file.
1 #ifndef __ZGEN_UTILS_HASHER_H__
2 #define __ZGEN_UTILS_HASHER_H__
3 
4 #include <cstring>
5 
6 namespace ZGen {
7 
8 namespace Utility {
9 
10 // Provide hash function for character array.
12  size_t operator() (const char* s) const {
13  unsigned int hashTemp = 0;
14  while (*s) {
15  hashTemp = hashTemp * 101 + *s ++;
16  }
17  return (size_t(hashTemp));
18  }
19 
20  bool operator() (const char* s1, const char* s2) const {
21  return (strcmp(s1, s2) < 0);
22  }
23 };
24 
25 // Provide an equal function for character array.
27  bool operator() (const char* s1, const char* s2) const {
28  return (strcmp(s1, s2) == 0);
29  }
30 };
31 
32 
33 }
34 
35 } // end for namespace ZGen
36 
37 #endif // end for __ZGEN_UTILS_HASHER_H__
bool operator()(const char *s1, const char *s2) const
Definition: hasher.h:27
size_t operator()(const char *s) const
Definition: hasher.h:12