定义一个杂凑表类
定义一个杂凑表类,要求用数组存放杂凑表元素,以字符串作关键字存放和查找表元素,并提供用于插入、查询和删除杂凑表元素的public函数成员。#include<string.h>
#include<alloc.h>
Class HASH{
class NODE{
int value;
NODE *next;
public:
int getvalue(){return value;}
NODE *getnext{return next;}
NODE *setnext(NODE *n){next=n;return this;}
NODE(int v,NODE *n){value=v;next=n}
~NODE(){if(next)delete next;}
}
struct BARREL{char *s;NODE *n;}*h;
int c;
const int t;
public:
HASH(int m);
NODE *lookup(const char *s,int v);
int insert(const char *s,int v);
int remove(const char *s,int v);
~HASH();
};