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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? d_stree.h

?? 自定義的二叉搜索樹(shù)的頭文件
?? H
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
#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)
{

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲三级免费电影| 色视频成人在线观看免| 美女久久久精品| 亚洲777理论| 无码av免费一区二区三区试看| 亚洲午夜视频在线| 亚洲激情自拍视频| 亚洲午夜一二三区视频| 亚洲国产人成综合网站| 亚洲妇女屁股眼交7| 五月综合激情网| 日本免费新一区视频| 美国精品在线观看| 国产寡妇亲子伦一区二区| 粉嫩欧美一区二区三区高清影视 | 亚洲国产成人av网| 五月婷婷激情综合网| 蜜臀久久99精品久久久久宅男| 久久激情五月激情| 风间由美一区二区三区在线观看| eeuss鲁一区二区三区| 色婷婷精品大在线视频| 欧美剧情电影在线观看完整版免费励志电影 | 国产精品你懂的在线欣赏| 国产精品久久精品日日| 一区二区高清免费观看影视大全| 午夜精品久久久久久不卡8050| 日韩不卡一二三区| 精品一区二区三区日韩| 国产成人鲁色资源国产91色综| 91亚洲精品久久久蜜桃| 欧美丰满一区二区免费视频| 久久婷婷久久一区二区三区| 亚洲欧洲美洲综合色网| 午夜在线成人av| 国产精品一区二区在线播放| 91在线观看免费视频| 欧美一级黄色大片| 国产精品色眯眯| 午夜精品久久久久久久99樱桃| 国内精品嫩模私拍在线| 91影院在线观看| 欧美大度的电影原声| 国产精品午夜在线| 丝袜国产日韩另类美女| 成人性视频免费网站| 欧美乱妇一区二区三区不卡视频| 久久久影视传媒| 亚洲国产va精品久久久不卡综合| 国产麻豆精品在线| 欧洲中文字幕精品| 国产欧美日韩一区二区三区在线观看| 亚洲一区免费视频| 国产盗摄精品一区二区三区在线 | 樱花影视一区二区| 久久aⅴ国产欧美74aaa| 91国偷自产一区二区三区观看| 精品久久久久久亚洲综合网 | 日韩你懂的电影在线观看| 国产精品美女久久久久aⅴ国产馆| 亚洲成人免费影院| 成人久久18免费网站麻豆 | 亚洲人成在线观看一区二区| 久久99精品国产.久久久久久| 日本道色综合久久| 国产欧美一区二区精品仙草咪| 性久久久久久久久| 色婷婷久久久亚洲一区二区三区| 久久久蜜桃精品| 蜜桃视频在线一区| 欧美综合一区二区| 国产精品二三区| 国产裸体歌舞团一区二区| 欧美美女一区二区| 亚洲激情图片qvod| kk眼镜猥琐国模调教系列一区二区| 精品国产乱码久久久久久久久 | 国产99久久精品| 欧美成人性福生活免费看| 午夜久久电影网| 欧美亚洲愉拍一区二区| 1024国产精品| www.亚洲精品| 中文字幕国产一区| 国产综合色在线视频区| 日韩欧美一区二区久久婷婷| 日韩和欧美的一区| 欧美日韩国产区一| 亚洲一区二区三区影院| 色综合久久久久综合体| 亚洲视频在线一区观看| 成人av网在线| 中文字幕五月欧美| caoporn国产精品| 国产精品青草综合久久久久99| 国产成人精品三级| 国产日韩欧美在线一区| 国产一区二区三区免费在线观看| 欧美成人猛片aaaaaaa| 另类人妖一区二区av| 欧美成人女星排行榜| 国内成+人亚洲+欧美+综合在线| 日韩欧美资源站| 玖玖九九国产精品| 欧美xxxxx牲另类人与| 另类中文字幕网| 久久亚洲二区三区| 成人精品国产福利| 综合婷婷亚洲小说| 色哟哟欧美精品| 亚洲观看高清完整版在线观看 | 久久亚洲一区二区三区四区| 国产精品一区二区久久不卡| 中文字幕电影一区| 91麻豆自制传媒国产之光| 一区二区三区四区不卡在线| 欧美亚洲一区三区| 蜜臀av一区二区在线观看| 久久综合狠狠综合久久综合88| 丁香亚洲综合激情啪啪综合| 国产精品国产精品国产专区不蜜| 色婷婷av一区二区三区之一色屋| 亚洲成人免费看| 精品国产乱码久久久久久久| 丁香另类激情小说| 亚洲一区二区中文在线| 91精品国产全国免费观看| 韩国一区二区视频| 国产精品麻豆一区二区 | 亚洲欧美一区二区视频| 在线一区二区三区做爰视频网站| 亚洲国产三级在线| 2023国产精品自拍| 色综合久久综合网97色综合| 日韩精品色哟哟| 国产欧美日韩三区| 欧美日韩在线电影| 国产毛片一区二区| 夜夜爽夜夜爽精品视频| 欧美大度的电影原声| 99国产精品久久久久久久久久久| 五月婷婷色综合| 国产人成一区二区三区影院| 欧美特级限制片免费在线观看| 国产一区二区久久| 亚洲午夜在线视频| 2020国产精品久久精品美国| 91国偷自产一区二区开放时间 | 日韩午夜在线观看| 成a人片国产精品| 免费一级片91| 亚洲女同一区二区| 精品sm捆绑视频| 欧美性生交片4| 国产sm精品调教视频网站| 亚洲一区二区在线观看视频| 国产亚洲成aⅴ人片在线观看| 欧美日韩亚洲综合一区二区三区| 国产成人免费视频网站| 日韩av一二三| 亚洲日本成人在线观看| 久久日韩粉嫩一区二区三区| 欧美色偷偷大香| 波多野结衣亚洲一区| 久久国产精品免费| 亚洲成人免费在线| 亚洲日本va在线观看| 久久夜色精品一区| 91精品国产乱码| 欧美视频在线播放| 色综合网站在线| 国产91在线观看丝袜| 麻豆精品视频在线观看视频| 亚洲成人免费影院| 亚洲欧洲制服丝袜| 欧美激情综合五月色丁香 | 首页国产欧美久久| 亚洲女人的天堂| 中文字幕巨乱亚洲| 久久综合色婷婷| 欧美一级二级三级乱码| 欧美日韩一区高清| 91色|porny| 99久久久国产精品| 成人亚洲一区二区一| 国产精品综合av一区二区国产馆| 日本麻豆一区二区三区视频| 亚洲午夜在线观看视频在线| 一区二区三区中文在线观看| 综合色天天鬼久久鬼色| 国产精品网曝门| 久久久不卡影院| www久久精品| 久久美女艺术照精彩视频福利播放| 日韩欧美国产综合一区| 欧美一级电影网站| 日韩欧美一级二级| 精品久久久三级丝袜| 欧美成人高清电影在线| 精品国产乱码久久久久久免费|