ZGen
0.2.0
a linearization system for natural language.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
utils
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.
11
struct
__Default_CharArray_Hash_Function
{
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.
26
struct
__Default_CharArray_Equal_Function
{
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__
ZGen::Utility::__Default_CharArray_Equal_Function::operator()
bool operator()(const char *s1, const char *s2) const
Definition:
hasher.h:27
ZGen::Utility::__Default_CharArray_Hash_Function::operator()
size_t operator()(const char *s) const
Definition:
hasher.h:12
ZGen::Utility::__Default_CharArray_Hash_Function
Definition:
hasher.h:11
ZGen::Utility::__Default_CharArray_Equal_Function
Definition:
hasher.h:26
Generated by
1.8.6