hashfn.cpp

来自「数据结构与程序设计教材源码 数据结构与程序设计教材源码」· C++ 代码 · 共 27 行

CPP
27
字号
const int factor = 101;
 
int hash(int row, int col)
/* 
Post: The function returns the hashed valued between
0 and hash_size - 1 that corresponds to the given
Cell parameter.
*/
{
   int value;
   value = row + factor * col;
   value %= hash_size;
   if (value < 0) return value + hash_size;
   else return value;
}
 
Error_code sequential_search(const List<Cell *> &the_list, int row, int col,
                             int &location, Cell *&found)
{
   int s = the_list.size();
   for (location = 0; location < s; location++) {
      the_list.retrieve(location, found);
      if (found->row == row && found->col == col) return success;
   }
   return not_present;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?