亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 描述3.txt

?? 9、優先級隊列 QueueNode.h Compare.h PriorityQueue.h Test.cpp 10、串 88 MyString.h MyString.cpp
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
9、優先級隊列	
QueueNode.h	
Compare.h	
PriorityQueue.h	
Test.cpp	
10、串	88
MyString.h	
MyString.cpp	
test.cpp	
11、二叉樹	
BinTreeNode.h	
BinaryTree.h	
Test.cpp	
12、線索二叉樹	
ThreadNode.h	
ThreadTree.h	
ThreadInorderIterator.h	
test.cpp	



9、優先級隊列

QueueNode.h

template<typename Type,typename Cmp> class PriorityQueue;

template<typename Type,typename Cmp> class QueueNode{
private:
	friend class PriorityQueue<Type,Cmp>;
	QueueNode(const Type item,QueueNode<Type,Cmp> *next=NULL)
		:m_data(item),m_pnext(next){}
private:
	Type m_data;
	QueueNode<Type,Cmp> *m_pnext;
};

Compare.h

template<typename Type> class Compare{	//處理一般比較大小
public:
	static bool lt(Type item1,Type item2);
};

template<typename Type> bool Compare<Type>::lt(Type item1, Type item2){
	return item1<item2;
}

struct SpecialData{
	friend ostream& operator<<(ostream& ,SpecialData &);
	int m_ntenor;
	int m_npir;
};

ostream& operator<<(ostream& os,SpecialData &out){
	os<<out.m_ntenor<<"   "<<out.m_npir;
	return os;
}

class SpecialCmp{		//處理特殊比較大小,用戶可添加適當的類
public:
	static bool lt(SpecialData item1,SpecialData item2);
};

bool SpecialCmp::lt(SpecialData item1, SpecialData item2){
	return item1.m_npir<item2.m_npir;
}

PriorityQueue.h

#include "QueueNode.h"
#include "Compare.h"

template<typename Type,typename Cmp> class PriorityQueue{	//Cmp is Designed for compare
public:
	PriorityQueue():m_prear(NULL),m_pfront(NULL){}
	~PriorityQueue(){
		MakeEmpty();
	}

	void MakeEmpty();               //make the queue empty
	void Append(const Type item);   //insert data
	Type Delete();                  //delete data
	Type GetFront();                //get data
    void Print();                   //print the queue
        
	bool IsEmpty() const{           
		return m_pfront==NULL;
	}
	

private:
	QueueNode<Type,Cmp> *m_prear,*m_pfront;
};

template<typename Type,typename Cmp> void PriorityQueue<Type,Cmp>::MakeEmpty(){
	QueueNode<Type,Cmp> *pdel;
	while(m_pfront){
		pdel=m_pfront;
		m_pfront=m_pfront->m_pnext;
		delete pdel;
	}
}

template<typename Type,typename Cmp> void PriorityQueue<Type,Cmp>::Append(const Type item){
	if(m_pfront==NULL){
		m_pfront=m_prear=new QueueNode<Type,Cmp>(item);
	}
	else{
		m_prear=m_prear->m_pnext=new QueueNode<Type,Cmp>(item);
	}
}

template<typename Type,typename Cmp> Type PriorityQueue<Type,Cmp>::Delete(){
	if(IsEmpty()){
		cout<<"There is no elements!"<<endl;
		exit(1);
	}
	QueueNode<Type,Cmp> *pdel=m_pfront,*pmove=m_pfront;
	while(pmove->m_pnext){  //get the minimize priority's data

        //cmp:: lt is used for compare the two data, if the front one 
        //      is less than the back, then return 1
		if(Cmp::lt(pmove->m_pnext->m_data,pdel->m_pnext->m_data)){
			pdel=pmove;
		}
		pmove=pmove->m_pnext;
	}

	pmove=pdel;
	pdel=pdel->m_pnext;
	pmove->m_pnext=pdel->m_pnext;
	Type temp=pdel->m_data;
	delete pdel;
	return temp;
}

template<typename Type,typename Cmp> Type PriorityQueue<Type,Cmp>::GetFront(){
	if(IsEmpty()){
		cout<<"There is no elements!"<<endl;
		exit(1);
	}
	QueueNode<Type,Cmp> *pdel=m_pfront,*pmove=m_pfront->m_pnext;
	while(pmove){   //get the minimize priority's data
		if(Cmp::lt(pmove->m_data,pdel->m_data)){
			pdel=pmove;
		}
		pmove=pmove->m_pnext;
	}
	return pdel->m_data;
}

template<typename Type,typename Cmp> void PriorityQueue<Type,Cmp>::Print(){
	QueueNode<Type,Cmp> *pmove=m_pfront;
	cout<<"front";

	while(pmove){
		cout<<"--->"<<pmove->m_data;
		pmove=pmove->m_pnext;
	}

	cout<<"--->rear"<<endl<<endl<<endl;
}

Test.cpp

#include <iostream>
#include <cstdlib>
using namespace std;

#include "PriorityQueue.h"

int main(){
	PriorityQueue<int,Compare<int> > queue;
	int init[10]={1,9,3,5,0,8,2,4,6,7};
	for(int i=0;i<10;i++){
		queue.Append(init[i]);
	}
	queue.Print();

	queue.Delete();

	queue.Print();

	system("pause");
	system("cls");
	
	PriorityQueue<SpecialData,SpecialCmp> spe_queue;
	int init2[5][2]={{34,2},{64,1},{18,3},{24,2},{55,4}};
	SpecialData data[5];
	for(int i=0;i<5;i++){
		data[i].m_npir=init2[i][1];
		data[i].m_ntenor=init2[i][0];
	}
	for(int i=0;i<5;i++){
		spe_queue.Append(data[i]);
	}
	spe_queue.Print();

    cout<<spe_queue.GetFront()<<endl<<endl;
	spe_queue.Delete();
	spe_queue.Print();
	
	
	return 0;
}
10、串

MyString.h

const int MAXSIZE=100;

class CMyString
{
public:
	CMyString(const CMyString& copy);
	CMyString(const char *init);
	CMyString();
	~CMyString(){
		delete[] m_pstr;
	}
	int Length() const{
		return m_ncurlen;
	}
	int Find(CMyString part) const;
	char* GetBuffer() const;

public:
	CMyString& operator()(int pos,int len);
	bool operator==(const CMyString cmp_str) const;
	bool operator!=(const CMyString cmp_str) const;
	bool operator<(const CMyString cmp_str) const;
	bool operator>(const CMyString cmp_str) const;
	bool operator!() const{
		return m_ncurlen==0;
	}
	CMyString& operator=(const CMyString &copy);
	CMyString& operator+=(const CMyString &add);
	char& operator[](int i);
	friend ostream& operator<<(ostream& ,CMyString&);
	friend istream& operator>>(istream& ,CMyString&);
private:
	void Next();

private:
	int m_ncurlen;
	char *m_pstr;
	int *m_pnext;
};

MyString.cpp

#include <iostream>
#include <cstring>

using namespace std;

#include "MyString.h"



CMyString::CMyString(){			//create empty string
	m_pstr=new char[MAXSIZE+1];
	if(!m_pstr){
		cerr<<"Allocation Error"<<endl;
		exit(1);
	}
	this->m_ncurlen=0;
	m_pstr[0]='\0';
}

CMyString::CMyString(const char *init){		//initialize the string with char*
	m_pstr=new char[MAXSIZE+1];
	if(!m_pstr){
		cerr<<"Allocation Error"<<endl;
		exit(1);
	}
	this->m_ncurlen=strlen(init);
	strcpy(m_pstr,init);
}

CMyString::CMyString(const CMyString &copy){	//initialize the string with string
	m_pstr=new char[MAXSIZE+1];
	if(!m_pstr){
		cerr<<"Allocation Error"<<endl;
		exit(1);
	}
	this->m_ncurlen=copy.m_ncurlen;
	strcpy(m_pstr,copy.m_pstr);
}

int CMyString::Find(CMyString part) const{		//string match :KMP
	int posP=0,posT=0;
	int lengthP=part.m_ncurlen,lengthT=this->m_ncurlen;

	part.Next();
	while(posP<lengthP&&posT<lengthT){
		if(part.m_pstr[posP]==this->m_pstr[posT]){
			posP++;
			posT++;
		}
		else{
			if(posP==0){
				posT++;
			}
			else{
				posP=part.m_pnext[posP-1];
			}
		}
	}
	delete[] part.m_pnext;
	if(posP<lengthP){
		return 0;
	}
	else{
		return 1;
	}
}

void CMyString::Next(){			//get the next char for matching : KMP
	int length=this->m_ncurlen;
	this->m_pnext=new int[length];
	this->m_pnext[0]=0;
	for(int i=1;i<length;i++){
		int j=this->m_pnext[i-1];
		while(*(this->m_pstr+i)!=*(this->m_pstr+j)&&j>0){
			j=this->m_pnext[j-1];
		}
		if(*(this->m_pstr+i)==*(this->m_pstr+j)){
			this->m_pnext[i]=j+1;
		}
		else{
			this->m_pnext[i]=0;
		}
	}
//	for(int i=0;i<length;i++)
//		cout<<i<<":\t"<<m_pnext[i]<<endl;
}

char *CMyString::GetBuffer() const{		//get the char* from string
	return this->m_pstr;
}

CMyString& CMyString::operator()(int pos, int len){		//get len char with the begining of pos
	CMyString *temp=new CMyString;
	if(pos<0||pos+len-1>MAXSIZE||len<0){
		temp->m_ncurlen=0;
		temp->m_pstr[0]='\0';
	}
	else{
		if(pos+len-1>=m_ncurlen){
			len=m_ncurlen-pos;
		}
		temp->m_ncurlen=len;
		for(int i=0,j=pos;i<len;i++,j++){
			temp->m_pstr[i]=m_pstr[j];
		}
		temp->m_pstr[len]='\0';
	}
	return *temp;
}

bool CMyString::operator==(const CMyString cmp_str) const{
	if(this->m_ncurlen!=cmp_str.m_ncurlen){
		return 0;
	}
	for(int i=0;i<this->m_ncurlen;i++){
		if(this->m_pstr[i]!=cmp_str.m_pstr[i])
			return 0;
	}
	return 1;
}
bool CMyString::operator!=(const CMyString cmp_str) const{
	if(*this==cmp_str)
		return 0;
	return 1;
}
bool CMyString::operator<(const CMyString cmp_str) const{
	if(this->m_ncurlen!=cmp_str.m_ncurlen){
		return this->m_ncurlen<cmp_str.m_ncurlen;
	}
	for(int i=0;i<this->m_ncurlen;i++){
		if(this->m_pstr[i]!=cmp_str.m_pstr[i]){
			return this->m_pnext[i]<cmp_str.m_pnext[i];
		}
	}
	return 0;
}
bool CMyString::operator>(const CMyString cmp_str) const{
	if(*this<cmp_str||*this==cmp_str){
		return 0;
	}
	return 1;
}
CMyString& CMyString::operator=(const CMyString &copy){		//賦值操作
	delete[] this->m_pstr;
	this->m_pstr=new char[copy.m_ncurlen+1];
	strcpy
		(this->m_pstr,copy.m_pstr);
	return *this;
}
CMyString& CMyString::operator+=(const CMyString &add){		//字符串追加
	int length=this->m_ncurlen+add.m_ncurlen;
	int n=this->m_ncurlen;
	CMyString temp(*this);
	delete[] this->m_pstr;
	this->m_pstr=new char[length+1];
	for(int i=0;i<n;i++){
		this->m_pstr[i]=temp[i];
	}
	for(int i=n;i<length;i++){
		this->m_pstr[i]=add.m_pstr[i-n];
	}
	this->m_pstr[length]='\0';
	return *this;
}
char& CMyString::operator[](int i){		//取元素
	if(i<0||i>=this->m_ncurlen){
		cout<<"out of boundary!"<<endl;
		exit(1);
	}
	return this->m_pstr[i];
}

ostream& operator<<(ostream& os,CMyString& str){
	os<<str.m_pstr;
	return os;
}

istream& operator>>(istream& is,CMyString& str){
	is>>str.m_pstr;
	return is;
}

test.cpp

#include <iostream>

using namespace std;

#include "MyString.h"

int main(){
	CMyString test1("babc");
	CMyString test2("abababcdefb");
	cout<<test2.Find(test1)<<endl;
	cout<<test2(2,3)<<endl;

	if(test1<test2){
		cout<<test1<<"<"<<test2<<endl;
	}
	else{
		if(test1==test2){
			cout<<test1<<"=="<<test2<<endl;
		}
		else{
			if(test1>test2){
				cout<<test1<<">"<<test2<<endl;
			}
		}
	}

	int length=test2.Length();
	for(int i=0;i<length;i++){
		cout<<test2[i];
	}
	cout<<endl;

	test1+=test2;
	cout<<test1<<endl;

	test1=test2;
	cout<<test1<<endl;

	return 0;
}
11、二叉樹

BinTreeNode.h

template<typename Type> class BinaryTree;

template<typename Type> class BinTreeNode{
public:
	friend class BinaryTree<Type>;
	BinTreeNode():m_pleft(NULL),m_pright(NULL){}
	BinTreeNode(Type item,BinTreeNode<Type> *left=NULL,BinTreeNode<Type> *right=NULL)
		:m_data(item),m_pleft(left),m_pright(right){}

	Type GetData() const;		//get thd data
	BinTreeNode<Type> *GetLeft() const;		//get the left node
	BinTreeNode<Type> *GetRight() const;	//get the right node

	void SetData(const Type data);			//change the data
	void SetLeft(const BinTreeNode<Type> *left);	//change thd left node
	void SetRight(const BinTreeNode<Type> *right);	//change the right node

	void InOrder();		//inorder the tree with the root of the node
	void PreOrder();	//perorder the tree with the root of the node
	void PostOrder();	//postoder the tree with the root of the node
	
	int Size();			//get size
	int Height();		//get height
	BinTreeNode<Type> *Copy(const BinTreeNode<Type> *copy);	//copy the node
	void Destroy(){		//destroy the tree with the root of the node
		if(this!=NULL){
			this->m_pleft->Destroy();
			this->m_pright->Destroy();
			delete this;
		}
	}

	friend bool equal<Type>(const BinTreeNode<Type> *s,const BinTreeNode<Type> *t);	//is equal?

private:
	BinTreeNode<Type> *m_pleft,*m_pright;
	Type m_data;
};

template<typename Type> Type BinTreeNode<Type>::GetData() const{
	return this!=NULL?m_data:-1;
}

template<typename Type> BinTreeNode<Type>* BinTreeNode<Type>::GetLeft() const{
	return this!=NULL?m_pleft:NULL;
}

template<typename Type> BinTreeNode<Type>* BinTreeNode<Type>::GetRight() const{
	return this!=NULL?m_pright:NULL;
}

template<typename Type> void BinTreeNode<Type>::SetData(const Type data){
	if(this!=NULL){
		m_data=data;
	}
}

template<typename Type> void BinTreeNode<Type>::SetLeft(const BinTreeNode<Type> *left){
	if(this!=NULL){
		m_pleft=left;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲日本一区二区| www激情久久| 一区二区三区四区国产精品| 97久久人人超碰| 一区二区免费在线| 精品视频一区二区不卡| 日韩av不卡一区二区| 欧美变态口味重另类| 国产乱码精品一区二区三区忘忧草 | 国产日本欧洲亚洲| 99综合电影在线视频| 玉米视频成人免费看| 欧美乱妇15p| 国内精品视频一区二区三区八戒| 久久久国产一区二区三区四区小说 | 精品日本一线二线三线不卡| 国产成人在线观看免费网站| 亚洲日本一区二区| 欧美一区二区免费观在线| 激情综合一区二区三区| 中文字幕一区二区三区不卡| 欧洲精品中文字幕| 久久国产视频网| 中文字幕在线不卡国产视频| 欧美日韩精品三区| 国产精品白丝av| 亚洲电影在线免费观看| www国产亚洲精品久久麻豆| 色综合久久久久网| 三级一区在线视频先锋| 中文字幕欧美日本乱码一线二线| 欧美性videosxxxxx| 国产美女娇喘av呻吟久久| 伊人夜夜躁av伊人久久| 精品第一国产综合精品aⅴ| 色94色欧美sute亚洲线路二| 久久精品噜噜噜成人av农村| 一区二区三区精品视频| 久久久久久免费网| 6080国产精品一区二区| av在线不卡电影| 久久97超碰色| 首页国产欧美日韩丝袜| 亚洲另类在线视频| www国产精品av| 在线播放欧美女士性生活| 成人h精品动漫一区二区三区| 奇米在线7777在线精品| 夜夜精品视频一区二区| 国产精品无圣光一区二区| 日韩精品最新网址| 欧美视频一区二区三区| 欧美一区二区三区播放老司机| 99精品视频一区| 国产**成人网毛片九色 | 日本不卡在线视频| 曰韩精品一区二区| 中文字幕不卡的av| 精品欧美久久久| 欧美夫妻性生活| 欧美日韩中字一区| 色噜噜夜夜夜综合网| 99久久免费视频.com| 国产不卡视频一区| 国产乱理伦片在线观看夜一区| 蜜芽一区二区三区| 免费一级片91| 另类欧美日韩国产在线| 日本美女一区二区| 日本最新不卡在线| 日本aⅴ精品一区二区三区| 亚洲午夜久久久久久久久电影网| 亚洲视频小说图片| 亚洲日本中文字幕区| 成人免费在线观看入口| 最新日韩在线视频| 国产精品久久久久久亚洲毛片| 久久久久国产一区二区三区四区| 久久久亚洲精品石原莉奈 | 国产精品一区二区x88av| 久久电影国产免费久久电影| 久久99精品国产麻豆婷婷 | 国产色91在线| 欧美激情一区三区| 国产精品人成在线观看免费 | 色悠悠久久综合| 日本大香伊一区二区三区| 一本久久a久久精品亚洲 | 欧美日韩一区二区三区不卡| 欧美日韩你懂的| 精品少妇一区二区三区免费观看 | 欧美变态口味重另类| 精品国产一区二区国模嫣然| 精品99999| 亚洲国产精品激情在线观看| 国产精品天美传媒| 亚洲永久精品大片| 日韩在线一二三区| 精品一区二区三区不卡| 粉嫩13p一区二区三区| 97精品国产露脸对白| 欧美视频一区二区三区四区| 91精品久久久久久久99蜜桃 | 亚洲电影在线播放| 蜜桃91丨九色丨蝌蚪91桃色| 国产精品一区专区| 一本色道久久综合亚洲91| 欧美老年两性高潮| 久久久www免费人成精品| 亚洲婷婷在线视频| 日本欧美大码aⅴ在线播放| 国产美女av一区二区三区| 色88888久久久久久影院按摩| 欧美丰满嫩嫩电影| 日韩高清电影一区| 久久99精品久久久久久| 99国内精品久久| 欧美二区三区的天堂| 久久亚洲春色中文字幕久久久| 亚洲欧美在线另类| 日本亚洲三级在线| 99久久婷婷国产综合精品电影| 欧美日韩亚州综合| 国产日韩欧美精品综合| 午夜日韩在线电影| 国产ts人妖一区二区| 欧美福利视频导航| 中文字幕一区二区三区不卡 | 欧美剧情片在线观看| 国产欧美精品一区二区三区四区 | 亚洲国产成人tv| 日韩免费看的电影| 亚洲欧洲精品一区二区精品久久久| 亚洲国产精品久久一线不卡| 成人一级视频在线观看| 色www精品视频在线观看| 国产欧美一区视频| 日韩av一二三| 在线精品视频免费观看| 中文字幕av一区二区三区免费看| 青青国产91久久久久久| 欧美综合天天夜夜久久| 欧美国产精品劲爆| 久久66热re国产| 91精品午夜视频| 亚洲高清不卡在线| 色欧美片视频在线观看在线视频| 精品福利在线导航| 免费久久精品视频| 69av一区二区三区| 午夜精品福利一区二区三区av| 99久久久国产精品| 国产蜜臀97一区二区三区| 极品尤物av久久免费看| 欧美一区日韩一区| 日韩国产精品久久久久久亚洲| 欧美自拍偷拍一区| 亚洲综合无码一区二区| 91麻豆国产精品久久| 亚洲欧洲日韩综合一区二区| 国产精品99久久久| 国产丝袜欧美中文另类| 国产一区二区日韩精品| 久久欧美中文字幕| 国内精品在线播放| 久久精品一区二区| 国产高清亚洲一区| 欧美韩国日本一区| 成人爱爱电影网址| 中文字幕亚洲一区二区av在线| 成人sese在线| 亚洲男人天堂一区| 欧美伊人久久久久久午夜久久久久| 最新欧美精品一区二区三区| 成人激情文学综合网| 中文字幕乱码久久午夜不卡| 不卡av在线免费观看| 亚洲人成在线观看一区二区| 色婷婷精品大在线视频| 亚洲一线二线三线久久久| 欧美精品日日鲁夜夜添| 天天做天天摸天天爽国产一区 | 国产99久久久国产精品免费看| 国产性天天综合网| 成人高清视频免费观看| 一区二区三区欧美久久| 在线电影院国产精品| 久久99久久久久| 日本一区二区在线不卡| 色婷婷av一区| 免费欧美在线视频| 欧美国产综合一区二区| 色婷婷亚洲精品| 男人操女人的视频在线观看欧美| 亚洲va欧美va国产va天堂影院| 欧美日韩1234| 国产精品一区二区久久精品爱涩| 中文字幕中文字幕中文字幕亚洲无线| 日本韩国欧美一区| 久久精品久久精品|