📄 ht_hash_5.cc
字号:
// file: ht_hash_2.cc//// isip include files//#include "hash_table.h"#include "hash_table_constants.h" // method: hash_lookup_cc//// arguments:// int_4* vec: (input) the vector to be looked up in the hash table// int_4 size: (input) the length of the vector// 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 vector in the hash table//Hash_cell* Hash_table::hash_lookup_cc(int_4* vec_a, int_4 size_a, int_4& index_a) { // check for empty table // if (cells_d == (Hash_cell**)NULL) { index_a = -1; return (Hash_cell*)NULL; } // index variables // int_4* key_vec = (int_4*)NULL; int_4 key_size = 0; Hash_cell* ocell = (Hash_cell*)NULL; // find the cell containing this string // index_a = hash_vector_cc(vec_a, size_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(key_vec, key_size); if ((key_size == size_a) && (memcmp(key_vec, vec_a, size_a * sizeof(int_4)) == 0)) { ocell = cell; break; } } // exit gracefully // return ocell;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -