📄 ht_hash_2.cc
字号:
// file: ht_hash_2.cc//// isip include files//#include "hash_table.h"#include "hash_table_constants.h" // method: hash_lookup_cc//// arguments:// char_1* str: (input) the string to be looked up in the hash table// int_4& index: (output) the hash index of the string//// return: a Hash_cell pointer to the cell containing this entry//// this method looks up an entry for the given string in the hash table//Hash_cell* Hash_table::hash_lookup_cc(char_1* str_a, int_4& index_a) { // check for empty table // if (cells_d == (Hash_cell**)NULL) { index_a = -1; return (Hash_cell*)NULL; } // index variables // char_1* wstr = (char_1*)NULL; Hash_cell* ocell = (Hash_cell*)NULL; // find the cell containing this string // index_a = hash_string_cc(str_a); for (Hash_cell* cell = cells_d[index_a]; cell != (Hash_cell*)NULL; cell = cell->get_next_cc()) { // get the key string in this cell // cell->get_key_cc(wstr); // compare with the input string // if (strcmp((char*)wstr, (char*)str_a) == 0) { ocell = cell; break; } } // exit gracefully // return ocell;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -