Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
ep7_9_1.h
Package: C_exercice_code.rar [view]
Upload User: wxcui2006
Upload Date: 2022-07-12
Package Size: 1274k
Code Size: 2k
Category:
source in ebook
Development Platform:
Visual C++
- #include<iostream>
- #include<cassert>
- using namespace std;
- template<typename T>class Queue;
- template<typename T>class Node{
- T info;
- Node<T> *link;
- public:
- Node(){link=NULL;}
- Node(T data,Node *l=NULL);
- T Getinfo(){return info;}; //获得结点数据
- Node<T>* Getlink(){return link;}; //获得结点的指针
- void Setinfo(T data){info=data}; //设置结点数据
- void Setlink(Node<T> * pNext){link=pNext;} //设置结点的指针
- };
- template<typename T> Node<T>::Node(T data,Node *l){
- info=data;
- link=l;
- };
- template<typename T>class list{
- Node<T> *front,*rear;
- public:
- list(){rear=front=NULL;} //构造一个空链
- ~list();
- bool IsEmpty(){ return front==NULL;} //链空否?
- void EnRear(const T &); //进链
- T DeFront(); //出链
- T GetFront(); //查看链头数据
- void MakeEmpty(); //置空链,与析构逻辑上不同,物理上一样
- void EnFront(const T &); //从链头入链
- };
- template<typename T>void list<T>::MakeEmpty(){
- Node<T> *temp;
- while(front!=NULL){
- temp=front;front=front->Getlink();delete temp;
- }
- }
- template<typename T>list<T>::~list(){MakeEmpty();}
- template<typename T>void list<T>::EnRear(const T &data){
- if(front==NULL) front=rear=new Node<T>(data,NULL);
- else {
- rear->Setlink(new Node<T>(data,NULL));
- rear=rear->Getlink();
- }
- }
- template<typename T>void list<T>::EnFront(const T &data){ //从链头入链
- Node<T> *p=new Node<T>(data,NULL);
- if(front==NULL) front=rear=p;
- else{
- p->Setlink(front);
- front=p;
- }
- }
- template<typename T>T list<T>::DeFront(){
- assert(!IsEmpty());
- Node<T> *temp=front;
- T data=temp->Getinfo();
- front=front->Getlink();
- delete temp;
- return data;
- }
- template<typename T>T list<T>::GetFront(){
- assert(!IsEmpty());
- return front->Getinfo();
- }