⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.h

📁 3D游戏开发需要用到BSP树来经行场景渲染的管理。本代码包含完整的BSP及文件生成实现
💻 H
字号:
#pragma once

template <class type>
class CList {
public:
	struct node {
				node(type& d, node *n): data(d), next(n) {};
		type	data;
		node	*next;
	};
			CList();
			~CList();
	void	PushFront(type t);
	type*	PopFront();
	type*	PeekFront();
	void	Clear();
	void	ClearData();
private:
	node	*head;
};


template <class type>
inline CList<type>::CList(): head(0) {};

template <class type>
inline CList<type>::~CList() {
	Clear();
}

template <class type>
inline void CList<type>::PushFront(type t) {
	node *n = new node(t, head);
	head = n;
}

template <class type>
inline type* CList<type>::PeekFront() {
	return head->data;
}

template <class type>
inline type* CList<type>::PopFront() {
	type *r = head->data;
	node *popped = head;
	head = head->next;
	delete popped;
	return r;
}

template <class type>
inline void CList<type>::Clear() {
	node *n = head;
	while(n) {
		node *cur = n;
		n = n->next;
		delete cur;
	}
	head = 0;
}

template <class type>
inline void CList<type>::ClearData() {
	node *n = head;
	while(n) {
		node *cur = n;
		n = n->next;
		delete cur->data;
		delete cur;
	}
	head = 0;
}
	

⌨️ 快捷键说明

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