int main(int argc, char *argv[]){ DictTable dict_table; for(int i=0; i<100000; i++) { int table_no=i; char table_name[64]; _c++grid">
赞
踩
说明:哈希函数使用除留余数法。
- #include "tableinfo.h"
- #include "dicttable.h"
- #include <stdio.h>
-
- int main(int argc, char *argv[])
- {
- DictTable dict_table;
-
- for(int i=0; i<100000; i++)
- {
- int table_no=i;
- char table_name[64];
- sprintf(table_name,"table-%d",i);
-
- TableInfo table_info(table_no,table_name);
- dict_table.add_new(table_info);
- }
-
- int ret;
- TableInfo table_info;
- ret = dict_table.get_table(99,table_info);
- if(ret < 0)
- {
- printf("can not find table %d\n",99);
- }
- else
- {
- printf("table_no = %d, table_name=%s\n",table_info.table_no,table_info.table_name);
- }
-
- ret = dict_table.get_table(2000,table_info);
- if(ret < 0)
- {
- printf("can not find table %d\n",2000);
- }
- else
- {
- printf("table_no = %d, table_name=%s\n",table_info.table_no,table_info.table_name);
- }
-
- fflush(stdout);
- return 1;
- }
https://gitee.com/zhangtongxueruanjiankaifa/implementation-of-hash-table
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。