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

📄 htab.h

📁 《c++ 实践之路》光盘中的源代码
💻 H
字号:
#if !defined (HTAB_H)
#define HTAB_H
// (c) Bartosz Milewski 2000
#include "List.h"

// Hash table of strings

class HTable
{
public:
	// The short list sequencer.
	// The client creates this sequencer
	// to search for a given string.
	class Seq: public List::Seq
	{
	public:
		Seq (HTable const & htab, char const * str)
			: List::Seq (htab.Find (str)) {}
	};

	friend class Seq;
public:
	explicit HTable (int size): _size (size)
	{
		_aList = new List [size];
	}
	~HTable ()
	{
		delete []_aList;
	}	
	// add another string->id mapping
	void Add (char const * str, int id);
private:
	// return a short list of candidates
	List const & Find (char const * str) const;
	// the hashing function
	int hash (char const * str) const;

	List	  * _aList; // an array of (short) lists
	int			_size;
};

#endif

⌨️ 快捷键说明

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