📄 statetable.cpp
字号:
// StateTable.cpp: implementation of the StateTable class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TONFA.h"
#include "StateTable.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
StateTable::StateTable()
{
for(int i=0;i<TABNUM;i++)
{
tableList[i].count=0;
tableList[i].next=NULL;
tableList[i].tail=NULL;
tableList[i].point.x=tableList[i].point.y=-1;
}
}
StateTable::~StateTable()
{
ListNode * p,*temp;
for(int i=0;i<TABNUM;i++)
{
p=tableList[i].next;
while(p!=NULL)
{
temp=p;
p=p->next;
delete temp;
}
}
}
void StateTable::Insert(int startState,int endState,char a)
{//startState表示初态,endstate表示接受状态
ListNode * currptr;
currptr=new ListNode(endState,a,NULL);
if(tableList[startState].next==NULL)
{
tableList[startState].next=currptr;
tableList[startState].tail=tableList[startState].next;
}
else
{
tableList[startState].tail->next=currptr;
tableList[startState].tail=currptr;
}
tableList[startState].count++;
}
void StateTable::ClearTable()
{
ListNode * p,*temp;
for(int i=0;i<TABNUM;i++)
{
p=tableList[i].next;
while(p!=NULL)
{
temp=p;
p=p->next;
delete temp;
}
tableList[i].count=0;
tableList[i].next=NULL;
tableList[i].tail=NULL;
tableList[i].point.x=tableList[i].point.y=-1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -