dictionary.h

来自「一个拼写检查程序」· C头文件 代码 · 共 50 行

H
50
字号
#ifndef  _DICTIONARY_H_ 
#define  _DICTIONARY_H_

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

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

using namespace std;
/*
complete the hash function encapsulated in class hash_function in dictionary.h.
*/
class hash_function
{
public:
    hash_function() {}

    unsigned int operator()( const string& s )  const {
		
        // Complete definition]
		unsigned int res = 0;
        for (int i = 0; i < s.size(); i++) {
            res = res * 3079 + 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:
	Dictionary(string filename);	//从文件读取单词存放到Dictionary中
};

#endif

⌨️ 快捷键说明

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