说明:哈希函数使用除留余数法。
使用
#include "tableinfo.h"#include "dicttable.h"#include 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 %dn",99); } else { printf("table_no = %d, table_name=%sn",table_info.table_no,table_info.table_name); } ret = dict_table.get_table(2000,table_info); if(ret < 0) { printf("can not find table %dn",2000); } else { printf("table_no = %d, table_name=%