projects
/
YACASL2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
hash.cの分離独立とソースコードの草取り
[YACASL2.git]
/
src
/
hash.c
diff --git a/src/hash.c
b/src/hash.c
new file mode 100644
(file)
index 0000000..
b673d53
--- /dev/null
+++ b/
src/hash.c
@@ -0,0
+1,9
@@
+/* ハッシュ値を取得する */
+unsigned hash(const char *key, int size){
+ unsigned hashval;
+
+ for(hashval = 0; *key != '\0'; key++){
+ hashval = *key + 31 * hashval;
+ }
+ return hashval % size;
+}