hashtable.h

来自「用可视化环境,实现LZW压缩算法 编程环境:VC6.0」· C头文件 代码 · 共 71 行

H
71
字号
// HashTable.h: interface for the HashTable class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HASHTABLE_H__31E4E0A3_2CF4_4933_A8B6_77FB3BFF4E70__INCLUDED_)
#define AFX_HASHTABLE_H__31E4E0A3_2CF4_4933_A8B6_77FB3BFF4E70__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include"SortedChain.h"
class BadInput{
public:
	BadInput(){}
};
class NoMem{
public:
	NoMem(){}
};
class element{
	
public:
	int code;
	unsigned long key;
	operator  long(){return key;}
/*	bool operator ==(unsigned long k){
		return key==k;
	}*/
	//friend void Compress();
	element& operator =(unsigned long y){
		key=y;return *this;}
};
class ele{
//	friend void Output1(int);
//	friend void Decompress();
public:
	int prefix;
	unsigned char suffix;
};


template<class E,class K>
class HashTable{
public:
	HashTable(int div=11);
	~HashTable(){
		delete[] ht;
	
	}
	bool Search(const K& k,E& e){
		return ht[k%D].Search(k,e);
	}
	HashTable<E,K>& Insert( E& e){
		ht[e%D].DistinctInsert(e);
		return *this;
	}

private:	
	int D;
    SortedChain<E,K>* ht;
};
template<class E,class K>
HashTable<E,K>::HashTable(int div){
	D=div;
	ht=new SortedChain<E,K>[D];

}


#endif // !defined(AFX_HASHTABLE_H__31E4E0A3_2CF4_4933_A8B6_77FB3BFF4E70__INCLUDED_)

⌨️ 快捷键说明

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