📄 tr_ht_hash_0.cc
字号:
// file: tr_ht_hash_0.cc//// isip include files//#include "train_hash_table.h"#include "train_hash_table_constants.h" // method: hash_insert_cc//// arguments:// Train_Hash_cell* cell : (input) the Train_Hash_cell to be copied and inserted// in the hash table//// return: a Train_Hash_cell* pointer to the Train_Hash_cell containing this entry//// this method inserts an entry for the given Train_Hash_cell in the hash// table using the standard hash function in Kernighan & Ritchie (pp// 145)//Train_Hash_cell* Train_Hash_table::hash_insert_cc(Train_Hash_cell* cell_a) { // index variable // int_4 index = (int_4)0; Train_Hash_cell* cell = (Train_Hash_cell*)NULL; char_1* str = (char_1*)NULL; if (mode_d == TRAIN_HASH_TABLE_STRING_DRIVEN) { // the string to hash // cell_a->get_key_cc(str); // make sure this string is not already hashed // cell = hash_lookup_cc(str); if (cell == (Train_Hash_cell*)NULL) { // the input Train_Trace needs to be added to the table // cell = cell_a; // get the hash index // index = hash_string_cc(str); // insert this cell in the table // cell->set_next_cc(cells_d[index]); cells_d[index] = cell; } // otherwise output error message and exit program // else { error_handler_cc((char_1*)"hash_insert_cc", (char_1*)"duplicate hashing of cell - each hash string must be unique"); exit(ISIP_PROTO_ERROR); } } else { int_4* vec = (int_4*)NULL; int_4 vec_size = 0; // vector // cell_a->get_key_cc(vec, vec_size); // make sure this string is not already hashed // cell = hash_lookup_cc(vec, vec_size); if (cell == (Train_Hash_cell*)NULL) { // the input trace needs to be added to the table // cell = cell_a; // insert this cell in the table // cell->set_next_cc(cells_d[index]); cells_d[index] = cell; } // otherwise output error message and exit program // else { error_handler_cc((char_1*)"hash_insert_cc", (char_1*)"duplicate hashing of cell - each hash string must be unique"); exit(ISIP_PROTO_ERROR); } } // exit gracefully // return cell;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -