?? stack.cpp
字號:
// Stack.cpp : implementation file
//
#include "stdafx.h"
#include "多邊形填充.h"
#include "Stack.h"
#include "malloc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStack
IMPLEMENT_DYNCREATE(CStack, CView)
CStack::CStack()
{
}
CStack::~CStack()
{
}
BEGIN_MESSAGE_MAP(CStack, CView)
//{{AFX_MSG_MAP(CStack)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStack drawing
void CStack::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CStack diagnostics
#ifdef _DEBUG
void CStack::AssertValid() const
{
CView::AssertValid();
}
void CStack::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CStack message handlers
CPoint CStack::GetTop()
{
if(top ==base )
return NULL;
CPoint e;
e=*(top -1);
return e;
}
void CStack::Push(CPoint e)
{
if((top -base)>=stacksize )
{
base =(CPoint *) realloc(base ,(stacksize +STACKINCREMENT)* sizeof(CPoint));
if(!base ) return;
top =base +stacksize ;
stacksize += STACKINCREMENT;
}
*top++ =e;
return;
}
void CStack::Init()
{
base =(CPoint *)malloc(STACK_INIT_SIZE * sizeof(CPoint));
if(!base ) return;
top =base ;
stacksize =STACK_INIT_SIZE;
return;
}
void CStack::Pop()
{
if(top ==base ) return;
e = * --top ;
}
int CStack::IsEmpty()
{
if(base ==top )
return 1;
else return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -