This source file includes following definitions.
- hash
1 #include "hash.h"
2
3 unsigned hash(int keyc, HKEY *keyv[], int tabsize)
4 {
5 unsigned hashval = 0;
6 enum {
7 HASHNUM = 31
8 };
9
10 for(int i = 0; i < keyc; i++) {
11 switch(keyv[i]->type) {
12 case CHARS:
13 for(int j = 0; keyv[i]->val.s[j]; j++) {
14 hashval = keyv[i]->val.s[j] + HASHNUM * hashval;
15 }
16 break;
17 case INT:
18 hashval = keyv[i]->val.i + HASHNUM * hashval;
19 break;
20 default:
21 break;
22 }
23 }
24 return (hashval % tabsize);
25 }