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

📄 dictionary.h

📁 ssd5 op4的答案
💻 H
字号:
//this is op4
//the author is liqinwei
//2007/12/1
#ifndef  _DICTIONARY_H_ 
#define  _DICTIONARY_H_

#include  <iostream>
#include  <vector>
#include  <list>
#include  <algorithm>
#include  <string>
#include  <fstream>

#include  "hashset.h"
#include  "hashset.cpp"

using namespace std;


class hash_function
{
public:
    hash_function() {}//the implement of class function
	unsigned int operator()( const string& s )  const
	{
		unsigned int mm = 7000;
		unsigned int res = 0;
		for (int i = 0; i < s.size(); i++) {
			res = res * mm + s[i];
		}
	 return res;
	}
};


class equality
{
public:
    equality() {}
    bool  operator()( const string& A, const string& B )  const {
		return  (A == B);
    }
};

class Dictionary: public HashSet<string, hash_function, equality> {

public:

	//the constructor of class dictionnary
	Dictionary(char* filename):HashSet<string, hash_function, equality>()
	{

		ifstream inf(filename);
		if (! inf) {
			cerr << "Could not open " << filename << "\n";
		}
	
		while (inf) {

			string line;
			getline(inf, line);
			insert(line);//insert the the entry to the dictionary
		}
	}

};

#endif

⌨️ 快捷键说明

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