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

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

?? d_stree.h

?? 自定義的二叉搜索樹的頭文件
?? H
?? 第 1 頁 / 共 2 頁
字號:
#ifndef BINARY_SEARCH_TREE_CLASS
#define BINARY_SEARCH_TREE_CLASS

#ifndef NULL
#include <cstddef>
#endif  // NULL

#include <iomanip>		// for setw()
#include <strstream>		// for format conversion
#include <string>			// node data formatted as a string
#include <queue>
#include <utility>		// pair class

#include "d_except.h"	// exception classes

using namespace std;

// declares a binary search tree node object
template <typename T>
class stnode
{
   public:
		// stnode is used to implement the binary search tree class
		// making the data public simplifies building the class functions

		T nodeValue;
			// node data
		stnode<T> *left, *right, *parent;
		// child pointers and pointer to the node's parent

      // constructor
		stnode (const T& item, stnode<T> *lptr = NULL, 
              stnode<T> *rptr = NULL, stnode<T> *pptr = NULL):
				nodeValue(item), left(lptr), right(rptr), parent(pptr)
		{}
};

// objects hold a formatted label string and the level,column
// coordinates for a shadow tree node
class tnodeShadow
{
	public:
		string nodeValueStr;	// formatted node value
		int level,column;
		tnodeShadow *left, *right;

		tnodeShadow ()
		{}
};

template <typename T>
class stree
{
	public:

// include the iterator nested classes
#include "d_stiter.h"

		stree();
			// constructor. initialize root to NULL and size to 0
		stree(T *first, T *last);
			// constructor. insert the elements from the pointer
			// range [first, last) into the tree
		stree(const stree<T>& tree);
			// copy constructor
		~stree();
			// destructor
		stree<T>& operator= (const stree<T>& rhs);
			// assignment operator

		iterator find(const T& item);
			// search for item. if found, return an iterator pointing
			// at it in the tree; otherwise, return end()
		const_iterator find(const T& item) const;
			// constant version

		int empty() const;
			// indicate whether the tree is empty
		int size() const;
			// return the number of data items in the tree

		pair<iterator, bool> insert(const T& item);
			// if item is not in the tree, insert it and
			// return a pair whose iterator component points
			// at item and whose bool component is true. if item
			// is in the tree, return a pair whose iterator
			// component points at the existing item and whose
			// bool component is false
			// Postcondition: the tree size increases by 1 if item
			// is not in the tree

		int erase(const T& item);
			// if item is in the tree, erase it and return 1;
			// otherwise, return 0
			// Postcondition: the tree size decreases by 1 if
			// item is in the tree

		void erase(iterator pos);
			// erase the item pointed to by pos.
			// Preconditions: the tree is not empty and pos points
			// to an item in the tree. if the tree is empty, the
			// function throws the underflowError exception. if the
			// iterator is invalid, the function throws the referenceError
			// exception.
			// Postcondition: the tree size decreases by 1

		void erase(iterator first, iterator last);
			// erase all items in the range [first, last).
			// Precondition: the tree is not empty. if the tree
			// is empty, the function throws the underflowError
			// exception.
			// Postcondition: the size of the tree decreases by
			// the number of elements in the range [first, last)

		iterator begin();
			// return an iterator pointing to the first item
			// inorder
		const_iterator begin() const;
			// constant version
		iterator end();
			// return an iterator pointing just past the end of
			// the tree data
		const_iterator end() const;
			// constant version

		void displayTree(int maxCharacters);
			// tree display function. maxCharacters is the
			// largest number of characters required to draw
			// the value of a node

	private:
		stnode<T> *root;
			// pointer to tree root
		int treeSize;
			// number of elements in the tree

		stnode<T> *getSTNode(const T& item,
									stnode<T> *lptr,stnode<T> *rptr, stnode<T> *pptr);
			// allocate a new tree node and return a pointer to it.
			// if memory allocation fails, the function throws the
			// memoryAllocationError exception

		stnode<T> *copyTree(stnode<T> *t);
			// recursive function used by copy constructor and assignment
			// operator to assign the current tree as a copy of another tree

		void deleteTree(stnode<T> *t);
			// recursive function used by destructor and assignment
			// operator to delete all the nodes in the tree

		stnode<T> *findNode(const T& item) const;
			// search for item in the tree. if it is in the tree,
			// return a pointer to its node; otherwise, return NULL.
			// used by find() and erase()

		tnodeShadow *buildShadowTree(stnode<T> *t, int level, int& column);
			// recursive function that builds a subtree of the shadow tree
			// corresponding to node t of the tree we are drawing. level is the
			// level-coordinate for the root of the subtree, and column is the
			// changing column-coordinate of the tree nodes

		void deleteShadowTree(tnodeShadow *t);
			// remove the shadow tree from memory after displayTree()
			// displays the binary search tree
};

template <typename T>
stnode<T> *stree<T>::getSTNode(const T& item,
			stnode<T> *lptr,stnode<T> *rptr, stnode<T> *pptr)
{
	stnode<T> *newNode;

	// initialize the data and all pointers
	newNode = new stnode<T> (item, lptr, rptr, pptr);
	if (newNode == NULL)
		throw memoryAllocationError("stree: memory allocation failure");

	return newNode;
}

template <typename T>
stnode<T> *stree<T>::copyTree(stnode<T> *t)
{
	stnode<T> *newlptr, *newrptr, *newNode;

	// if tree branch NULL, return NULL
	if (t == NULL)
		return NULL;
  
	// copy the left branch of root t and assign its root to newlptr
	newlptr = copyTree(t->left);

	// copy the right branch of tree t and assign its root to newrptr
	newrptr = copyTree(t->right);

	// allocate storage for the current root node, assign
	// its value and pointers to its left and right subtrees.
	// the parent pointer of newNode is assigned when
	// newNode's parent is created. if newNode is root,
	// NULL is the correct value for its parent pointer
	newNode = getSTNode(t->nodeValue, newlptr, newrptr, NULL);

	// the current node is the parent of any subtree that
	// is not empty
	if (newlptr != NULL)
		newlptr->parent = newNode;
	if (newrptr != NULL)
		newrptr->parent = newNode;

	return newNode;
}

// delete the tree stored by the current object
template <typename T>
void stree<T>::deleteTree(stnode<T> *t)
{
	// if current root node is not NULL, delete its left subtree,
	// its right subtree and then the node itself
	if (t != NULL)
	{
		deleteTree(t->left);
		deleteTree(t->right);
		delete t;
	}
}

// search for data item in the tree. if found, return its node
// address; otherwise, return NULL
template <typename T>
stnode<T> *stree<T>::findNode(const T& item) const
{   
	// cycle t through the tree starting with root
	stnode<T> *t = root;

	// terminate on on empty subtree
	while(t != NULL && !(item == t->nodeValue))
		if (item < t->nodeValue)
			t = t->left;
		else 
			t = t->right;

	// return pointer to node; NULL if not found
	return t;
}

template <typename T>
stree<T>::stree(): root(NULL),treeSize(0)
{}

template <typename T>
stree<T>::stree(T *first, T *last): root(NULL),treeSize(0)
{
	T *p = first;

	// insert each item in [first, last) into the tree
	while (p != last)
	{
		insert(*p);
		p++;
	}
}

template <typename T>
stree<T>::stree(const stree<T>& tree): treeSize(tree.treeSize)
{
	// copy tree to the current object
	root = copyTree(tree.root);
}

template <typename T>
stree<T>::~stree()
{
	// erase the tree nodes from memory
	deleteTree(root);

	// tree is emtpy
	root = NULL;
	treeSize = 0;
}

template <typename T>
stree<T>& stree<T>::operator= (const stree<T>& rhs)
{
	// can't copy a tree to itself
	if (this == &rhs)
		return *this;

	// erase the existing tree nodes from memory
	deleteTree(root);

	// copy tree rhs into current object
	root = copyTree(rhs.root);

	// set the tree size
	treeSize = rhs.treeSize;

	// return reference to current object
	return *this;
}

template <typename T>
stree<T>::iterator stree<T>::find(const T& item)
{
	stnode<T> *curr;

	// search tree for item
	curr = findNode (item);

	// if item found, return const_iterator with value current;
	// otherwise, return end()
	if (curr != NULL)
		return iterator(curr, this);
	else
		return end();
}

template <typename T>
stree<T>::const_iterator stree<T>::find(const T& item) const
{
	stnode<T> *curr;

	// search tree for item
	curr = findNode (item);

	// if item found, return const_iterator with value current;
	// otherwise, return end()
	if (curr != NULL)
		return const_iterator(curr, this);
	else
		return end();
}

template <typename T>
int stree<T>::empty() const
{
	return root == NULL;
}

template <typename T>
int stree<T>::size() const
{
	return treeSize;
}

template <typename T>
pair<stree<T>::iterator, bool> stree<T>::insert(const T& item)
{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩手机在线导航| 一区二区三区四区在线免费观看 | 亚洲宅男天堂在线观看无病毒| 亚洲观看高清完整版在线观看| 亚洲视频电影在线| 欧美剧情片在线观看| 精品美女被调教视频大全网站| 亚洲欧洲日韩一区二区三区| 久久97超碰国产精品超碰| 欧美最猛性xxxxx直播| 国产欧美精品在线观看| 美女网站色91| 91成人免费网站| 国产精品高潮呻吟久久| 黄色日韩网站视频| 日韩一级片网站| 国产99精品国产| 欧美一区二区三区在线视频 | 91老师国产黑色丝袜在线| 久久蜜桃香蕉精品一区二区三区| 亚洲成人av在线电影| 99精品偷自拍| 中文字幕在线一区二区三区| 国产精品伊人色| 2021久久国产精品不只是精品| 亚洲成av人片| 欧美精品久久久久久久多人混战 | 色综合天天综合色综合av | wwwwxxxxx欧美| 蜜乳av一区二区| 日韩一区二区在线观看视频播放| 视频一区视频二区中文| 欧美日本视频在线| 亚洲成a人v欧美综合天堂| 欧美日韩精品电影| 婷婷久久综合九色综合绿巨人| 欧美无乱码久久久免费午夜一区| 亚洲一区二区三区在线看| 在线亚洲人成电影网站色www| 国产精品国产三级国产普通话三级 | 欧美日本精品一区二区三区| 三级精品在线观看| 日韩一区二区三区四区五区六区| 五月婷婷欧美视频| 日韩一区二区视频在线观看| 国模冰冰炮一区二区| 欧美一区二区不卡视频| 精彩视频一区二区三区| 久久久久久久综合| av福利精品导航| 亚洲国产一区二区三区 | 久久久精品免费免费| 国产91精品一区二区麻豆亚洲| 国产日产欧美一区二区视频| eeuss鲁片一区二区三区在线看| 国产日产欧美精品一区二区三区| 欧美放荡的少妇| 久久99久久精品欧美| 久久九九99视频| 欧美综合在线视频| 国产在线视频一区二区| 日本一区二区三区电影| 欧美专区在线观看一区| 蜜桃久久久久久| 国产亚洲欧美色| 欧美性大战久久久| 国产毛片精品国产一区二区三区| 国产精品国产三级国产aⅴ原创| 91黄色在线观看| 国内久久精品视频| 亚洲欧美国产三级| 精品国产一区二区亚洲人成毛片| 99久久久久免费精品国产| 七七婷婷婷婷精品国产| 国产精品福利一区| 日韩午夜av电影| aaa国产一区| 激情综合色丁香一区二区| 亚洲精品日日夜夜| 久久久久国色av免费看影院| 精品视频在线视频| 成人自拍视频在线观看| 日韩高清不卡在线| 亚洲色图视频免费播放| 久久婷婷色综合| 欧美精选一区二区| 99re这里都是精品| 国产综合久久久久久久久久久久| 亚洲综合免费观看高清完整版 | 欧美日韩成人在线| 成人激情午夜影院| 国产一区在线视频| 亚洲bt欧美bt精品777| www精品美女久久久tv| 国产麻豆成人传媒免费观看| 亚洲成人动漫在线免费观看| 26uuu成人网一区二区三区| 91片在线免费观看| 日韩伦理电影网| 亚洲成人手机在线| 91精品国产aⅴ一区二区| 日韩一区精品字幕| 久久蜜臀精品av| 91精品在线观看入口| 亚洲va韩国va欧美va精品| 欧美白人最猛性xxxxx69交| 久久99精品久久久久久动态图 | 福利一区在线观看| 日日摸夜夜添夜夜添亚洲女人| 亚洲精品免费一二三区| 1024成人网色www| 国产精品理论在线观看| 国产精品麻豆欧美日韩ww| 国产婷婷精品av在线| 亚洲国产精品激情在线观看| 2020国产精品久久精品美国| 日韩精品一区二区三区四区视频 | 五月激情丁香一区二区三区| 一区二区三区在线视频免费 | 欧美熟乱第一页| 在线免费精品视频| 欧美日韩在线观看一区二区| 欧美色图激情小说| 欧美精品第一页| 日韩欧美国产小视频| 久久网这里都是精品| 国产精品无码永久免费888| 国产精品嫩草99a| 综合中文字幕亚洲| 亚洲国产精品综合小说图片区| 偷拍自拍另类欧美| 精品亚洲欧美一区| 成人一二三区视频| 色偷偷久久一区二区三区| 欧美日韩一区不卡| 欧美精品一区视频| 中文字幕日本不卡| 亚洲国产日产av| 加勒比av一区二区| 不卡在线视频中文字幕| 欧美情侣在线播放| 欧美精品一区二区高清在线观看 | caoporn国产一区二区| 欧美色图天堂网| 日韩欧美美女一区二区三区| 国产午夜精品福利| 亚洲小说春色综合另类电影| 国产综合色视频| 色综合久久综合中文综合网| 欧美一级二级在线观看| 国产精品免费aⅴ片在线观看| 亚洲综合在线视频| 欧美本精品男人aⅴ天堂| 欧美一区二区在线不卡| 国产99精品视频| 欧美精品一区二区三区蜜臀| 亚洲精品欧美激情| 精品一区中文字幕| 欧美亚洲动漫精品| 国产日本一区二区| 日韩精品三区四区| 97久久超碰国产精品电影| 日韩一级高清毛片| 亚洲欧美国产毛片在线| 国产69精品一区二区亚洲孕妇| 欧美日韩亚洲高清一区二区| 日韩一区二区免费高清| 中文字幕精品一区二区三区精品| 日韩av电影免费观看高清完整版 | 成人av动漫网站| 日韩欧美国产精品一区| 136国产福利精品导航| 九一九一国产精品| 欧美三级日本三级少妇99| 亚洲欧洲精品一区二区三区| 国产制服丝袜一区| 日韩欧美成人一区二区| 亚洲国产一二三| 91在线你懂得| 国产精品乱码妇女bbbb| 九九九精品视频| 欧美一级日韩一级| 亚洲3atv精品一区二区三区| 97久久超碰国产精品电影| 国产精品无人区| 国产.欧美.日韩| 国产欧美一区二区精品性色超碰| 美女脱光内衣内裤视频久久网站 | 99国产麻豆精品| 欧美精彩视频一区二区三区| 国产在线视视频有精品| 精品国偷自产国产一区| 卡一卡二国产精品| 欧美一卡二卡三卡四卡| 日韩国产精品久久久久久亚洲| 在线观看日韩电影| 亚洲一区二区黄色| 欧美日韩精品一区二区三区四区| 亚洲国产va精品久久久不卡综合| 91福利视频久久久久|