vertexstack.cpp
来自「这是我写的数据结构的课设」· C++ 代码 · 共 60 行
CPP
60 行
// VertexStack.cpp: implementation of the CVertexStack class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CollegeWizard.h"
#include "VertexStack.h"
#include "Vertex.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVertexStack::CVertexStack()
{
list = NULL;
}
CVertexStack::~CVertexStack()
{
struct node* temp = list;
while(temp)
{
list = list->next;
delete temp;
temp = list;
}
}
//////////////////////////////////////////////////////////////////////
CVertex* CVertexStack::Pop()
{
struct node* temp = list;
if(list)
{
list = list->next;
return temp->vertex;
delete temp;
}
else return NULL;
}
void CVertexStack::Push(CVertex *vertex1)
{
struct node* temp = new node;
temp->next = list;
temp->vertex = vertex1;
list = temp;
}
BOOL CVertexStack::IsEmpty()
{
return list == NULL? TRUE : FALSE;
}
//////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?