listnode.cpp

来自「蒙特卡罗方法可以有效地解决复杂的工程问题」· C++ 代码 · 共 122 行

CPP
122
字号
// ListNode.cpp: implementation of the CListNode class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "RayTrace.h"

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

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

//构造函数,初始化指针
CListNode::CListNode()
{
	next = NULL ;
	pre = NULL ;
}

//析构函数,指针置空
CListNode::~CListNode()
{
	next = NULL ;
	pre = NULL ;
}

/*************************************************************************
 *
 * 函数名称:
 *   CListNode::SetNext
 *
 * 参数:
 *   CListNode *newnode			- 要插入链表的结点指针
 *
 * 返回值:
 *   无
 *
 * 说明:
 *   链表插入操作,在当前结点的后面插入新结点。
 *
 ************************************************************************/
void CListNode::SetNext(CListNode *newnode)
{
	ASSERT( newnode != NULL );

	newnode->next = next;
	next = newnode;
	newnode->pre = this;
	newnode->next->pre = newnode;
}

/*************************************************************************
 *
 * 函数名称:
 *   CListNode::SetPre
 *
 * 参数:
 *   CListNode *newnode			- 要插入链表的结点指针
 *
 * 返回值:
 *   无
 *
 * 说明:
 *   链表插入操作,在当前结点的前面插入新结点。
 *
 ************************************************************************/
void CListNode::SetPre(CListNode *newnode)
{
	ASSERT( newnode != NULL );
	ASSERT( pre != NULL );

	newnode->next = this;
	newnode->pre = pre;
	pre->next = newnode;
	pre = newnode;
}

/*************************************************************************
 *
 * 函数名称:
 *   CListNode::GetNext()
 *
 * 参数:
 *   无
 *
 * 返回值:
 *   CListNode*			- 返回当前结点后面的结点指针
 *
 * 说明:
 *   链表操作,获取当前结点后面的结点。
 *
 ************************************************************************/
CListNode* CListNode::GetNext()
{
	return next;
}

/*************************************************************************
 *
 * 函数名称:
 *   CListNode::GetPre()
 *
 * 参数:
 *   无
 *
 * 返回值:
 *   CListNode*			- 返回当前结点前面的结点指针
 *
 * 说明:
 *   链表操作,获取当前结点前面的结点。
 *
 ************************************************************************/
CListNode* CListNode::GetPre()
{
	return pre;
}

⌨️ 快捷键说明

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