📄 fact.cpp
字号:
// Fact.cpp: implementation of the CFact class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Fact.h"
#include "mineDabse.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFactChain::CFactChain()
{
headFact=NULL;
}
CFactChain::~CFactChain()
{
DestroyChain();
}
void CFactChain::DestroyChain(){
CFact* nodeTemp;
while(NULL!=headFact){
nodeTemp=headFact->next;
delete headFact;
headFact=nodeTemp;
}
}
//////////
void CFactChain::appendFact(CString fact_str)
{
CFact* nodeTemp=new CFact(),*p;
//nodeTemp->name=name_str;
nodeTemp->fact=fact_str;
nodeTemp->next=NULL;
p=headFact;
if(p==NULL){
headFact=nodeTemp;
nodeTemp->next=NULL;
}
else{
while((NULL!=p->next)&&(p->fact!=fact_str)){
//p->fact!=fact_str防止出现多个相同的事实
p=p->next;
}
//nodeTemp->next=p->next;
if(p->next==NULL)
p->next=nodeTemp;
else delete nodeTemp;
}
}
//////////////////////
void CFactChain::deleteFact(CString fact)
{
CFact* nodeTemp=NULL,*pNode=NULL;
pNode=nodeTemp=headFact;
while(0!=(nodeTemp->fact.Compare(fact))&&(nodeTemp!=NULL)){
pNode=nodeTemp;
nodeTemp=nodeTemp->next;//没找到要删除的节点,goon
}
if(!nodeTemp){
AfxMessageBox("没有要删除的节点");
return;
}
//pNode=nodeTemp;
//if(pNode!=NULL)
// nodeTemp->next=pNode->next;
//else
//nodeTemp->next=NULL;
//pNode指向要删除RuleNode节点的前趋
if(pNode->next==NULL)
headFact=NULL;
else
if (headFact==nodeTemp)//删除第一个节点
headFact=pNode->next;
else
pNode->next=nodeTemp->next;
delete nodeTemp;
nodeTemp=NULL;
}
///////////////
bool CFactChain::isEmpty()
{
if (headFact==NULL){
// AfxMessageBox("链表空!");
return true;
}
else return false;
}
CFact* CFactChain::getHead()
{
return headFact;
}
CFact* CFactChain::nextFact(CFact *node)
{
if (NULL==node){
AfxMessageBox("错误!");
exit(0);
}
else
return node->next;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -