⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htab.cpp

📁 《c++ 实践之路》光盘中的源代码
💻 CPP
字号:
// (c) Bartosz Milewski 2000
#include "HTab.h"
#include <cassert>

// Find the list in the hash table that may contain
// the id of the string we are looking for

List const & HTable::Find (char const * str) const
{
	int i = hash (str);
	return _aList [i];
}

void HTable::Add (char const * str, int id)
{
	int i = hash (str);
	_aList [i].Add (id);
}

int HTable::hash (char const * str) const
{
	// no empty strings, please
	assert (str != 0 && str [0] != 0);
	unsigned h = str [0];
	for (int i = 1; str [i] != 0; ++i)
		h = (h << 4) + str [i];
	return h % _size; // remainder
}


⌨️ 快捷键说明

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