YACASL2
src
hash.c
Go to the documentation of this file.
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
}
hash
unsigned hash(int keyc, HKEY *keyv[], int tabsize)
ハッシュ値を取得する
Definition:
hash.c:3
hash.h
CHARS
@ CHARS
Definition:
hash.h:8
INT
@ INT
Definition:
hash.h:9
HKEY
ハッシュ共用体のデータ型
Definition:
hash.h:15
HKEY::s
char * s
Definition:
hash.h:18
HKEY::i
int i
Definition:
hash.h:19
HKEY::val
union HKEY::@3 val
Generated on Mon Oct 2 2023 23:33:52 for YACASL2 by
1.9.1