This source file includes following definitions.
- hash_char2
- hash_int2
- hash_char2_int2
- main
1 #include <stdio.h>
2 #include "hash.h"
3 #include <string.h>
4 #include <stdlib.h>
5
6 unsigned hash_char2(int tsize)
7 {
8 char *str[2] = {"abc", "123"};
9 int i;
10 HKEY *keys[2];
11
12
13 for(i = 0; i < 2; i++) {
14 keys[i] = malloc(sizeof(HKEY));
15 keys[i]->type = CHARS;
16 keys[i]->val.s = strdup(str[i]);
17 }
18
19 return hash(2, keys, tsize);
20 }
21
22 unsigned hash_int2(int tsize)
23 {
24 int num[2] = {19, 11}, i;
25 HKEY *keys[2];
26
27
28 for(i = 0; i < 2; i++) {
29 keys[i] = malloc(sizeof(HKEY));
30 keys[i]->type = INT;
31 keys[i]->val.i = num[i];
32 }
33
34 return hash(2, keys, tsize);
35 }
36
37 unsigned hash_char2_int2(int tsize)
38 {
39 char *str[2] = {"abc", "123"};
40 int num[2] = {19, 11}, i, cnt = 0;
41 HKEY *keys[4];
42
43
44 for(i = 0; i < 2; i++) {
45 keys[cnt] = malloc(sizeof(HKEY));
46 keys[cnt]->type = CHARS;
47 keys[cnt++]->val.s = strdup(str[i]);
48 }
49 for(i = 0; i < 2; i++) {
50 keys[cnt] = malloc(sizeof(HKEY));
51 keys[cnt]->type = INT;
52 keys[cnt++]->val.i = num[i];
53 }
54
55 return hash(4, keys, tsize);
56 }
57
58 int main()
59 {
60 int tsize = 31;
61
62 printf("HASH VALUE: %d\n", hash_char2(tsize));
63 printf("HASH VALUE: %d\n", hash_int2(tsize));
64 printf("HASH VALUE: %d\n", hash_char2_int2(tsize));
65 return 0;
66 }