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

📄 clinkedlist.h

📁 一个可以存放任何数据类型的链表类
💻 H
字号:
#ifndef NULL
#define NULL 0
#endif

#include "stdio.h"

// 数据节点数据结构
template <class T>
class Node
{
	public:
		T data;
		Node * next;
	public:
		void SetNext(Node<T> *);
		Node<T> * GetNext();
		T GetData();
};

// 注意:链表元素下标从1开始,0号位置为链表的头,链表头是不装数据的
template <class T>
class CLinkedList
{
	private:
		Node<T> * head;
		Node<T> * tail;
	protected:
		bool CreateLinkedList();
		bool DestoryLinkedList();
	public:
		CLinkedList();
		~CLinkedList();
		T GetElement(int);
		bool AddElement(Node<T> *);
		bool InsertElement(Node<T> *,int);
		int GetLinkedListLength();
		bool DeleteElement(int);
		bool DeleteAll();
};

⌨️ 快捷键说明

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