bihashtable.h

来自「我们一个小组」· C头文件 代码 · 共 27 行

H
27
字号
#pragma once

#include <string>
#include <hash_map>

using std::string ;
using stdext::hash_map ;


//a bidirectional-hash-table which can get id by word as well as get word by id
class BiHashTable
{
public:
	BiHashTable() ;
	bool GetIDByWord(const string& strWord, int& nId) ;
	bool GetWordByID(int nId, string& strWord) ;
	bool GetIDAndInsertByWord(const string& strWord, int &nId) ;
	int GetCount() ;
	bool Save(const string& strFilename) ;
	bool Load(const string& strFilename) ;

private:
	hash_map<string, int> m_Word2IdMap ;
	hash_map<int, string> m_Id2WordMap ;
	int m_count ;
};

⌨️ 快捷键说明

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