#define FALSE 0
#endif
typedef int BOOL;
#include "Node.h"
template class List //单链表定义
{
//基本上无参数的成员函数操作的都是当前节点,即current指的节点
//认为表中“第1个节点”是第0个节点,请注意,即表长为1时,最后一个节点是第0个节点
public:
List() { first = current = last = new Node; prior = NULL; }
~List() { MakeEmpty(); delete first; }
void MakeEmpty() //置空表
{
Node *q;
while (first->link != NULL)
{
q = first->link;
first->link = q->link;
delete q;
}
Initialize();
}
BOOL IsEmpty()
{
if (first->link == NULL)
{
Initialize();
return TURE;
}
else return FALSE;
}
int Length() const //计算带表头节点的单链表长度
{
Node *p = first->link;
int count = 0;
while (p != NULL)