queue.cpp

来自「一些自己做的关于图象处理的程序(如傅立叶变换」· C++ 代码 · 共 74 行

CPP
74
字号
// Queue.cpp: implementation of the CQueue class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "photostar.h"
#include "Queue.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CQueue::CQueue()
{

}

CQueue::~CQueue()
{

}

BOOL CQueue::DeQueue(int &e)
{
	if (front==rear)
	{
		return FALSE;
	}
	QueuePtr p=front->next;
	e=p->data;
	front->next=p->next;
	if (rear==p)
	{
		rear=front;
	}
	free(p);
	return TRUE;
}

void CQueue::EnQueue(int e)
{
	QueuePtr p=new QNode;
	p->data=e;
	p->next=NULL;
	rear->next=p;
	rear=p;
	return;
}

void CQueue::DestroyQueue()
{
	while (front)
	{
		rear=front->next;
		delete front;
		front=rear;
	}
	return;
}

void CQueue::InitQueue()
{
	front = rear = new QNode;
	front->next = NULL;
	
	return;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?