list.h
来自「Astar 精灵版本 Astar 精灵版本」· C头文件 代码 · 共 28 行
H
28 行
#pragma once
#include "list.h"
#include <iostream>
using namespace std;
template <class Type> class List;
template <class Type> class Node
{
Type contents;
Node * next;
friend List<Type>;
};
template <class Type> class List
{
public:
List();
~List();
bool IsEmpty() const {return (pHead==NULL) ? true : false;}//判断链表是否为空
int Length() const {return length;} //返回链表中的元素总数
bool Find(int k, Type & intnum) const; //寻找链表中的第k个元素,并将其传送至intnum
int Search(const Type & intnum) const; //寻找intnum,如果发现intnum,则返回intnum的位置,如果intnum不在链表中,则返回0
void Delete(int k, Type & intnum); //把第k个元素取至intnum,然后从链表中删除第k个元素
void Insert(int k, const Type &intnum); //在第k个元素之后插入intnum
void Modify(int k,const Type &intum);//将第k个元素的值修改为intnum
void ShowListNode(); //显示输出链表的所有数据
private:
Node<Type> *pHead;
int length;
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?