📄 rulechain.cpp
字号:
// RuleChain.cpp: implementation of the RuleChain class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mineDabse.h"
#include "RuleChain.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
RuleChain::RuleChain()
{//无头结点
head=NULL;
}
RuleChain::~RuleChain()
{
DestroyChain();
}
////////////////
void RuleChain::DestroyChain(){
RuleNode* nodeTemp;
while(NULL!=head){
nodeTemp=head->next;
delete head;
head=nodeTemp;
}
}
//////////
void RuleChain::appendRule(CString&name,CString &pre,CString &con,bool flag)
{
RuleNode* nodeTemp=new RuleNode(name,pre,con,flag),*p;
p=head;
if(p==NULL){
head=nodeTemp;
nodeTemp->next=NULL;
}
else{
while(NULL!=p->next){
p=p->next;
}
nodeTemp->next=p->next;
p->next=nodeTemp;
}
}
//////////////////////
void RuleChain::deleteRule(CString* name)
{
RuleNode* nodeTemp=NULL,*pNode=NULL;
nodeTemp=head;
while((nodeTemp->name.Compare(*name))&&(nodeTemp!=NULL)){
nodeTemp=nodeTemp->next;//没找到要删除的节点,goon
}
if(!nodeTemp){
AfxMessageBox("没有要删除的节点");
return;
}
pNode=nodeTemp->next;//pNode指向要删除的RuleNode节点
nodeTemp->next=pNode->next;
delete pNode;
}
///////////////
bool RuleChain::isEmpty()
{
if (head==NULL){
// AfxMessageBox("链表空!");
return true;
}
else return false;
}
RuleNode* RuleChain::nextRule(RuleNode* node)
{
//if(node->next!=NULL)
return node->next;
}
RuleNode* RuleChain::getFirstRule()
{
return head;
}
RuleNode::RuleNode(CString name,CString premise,CString con,bool flag)
{/*nodeTemp->name=name;
nodeTemp->premise=pre;
nodeTemp->conclusion=con;
nodeTemp->flag=flag;
nodeTemp->next=NULL;*/
this->name=name;
this->premise=premise;
this->conclusion=con;
this->next=NULL;
this->flag=flag;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -