⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threaditerator.h

📁 数据结构c++-书的一些源代码
💻 H
字号:
template <class T> class ThreadIterator
{
	protected:
		BiTrThNode<T> *root;
		BiTrThNode<T> *current;
		int nextComplete;				//正序遍历尾部标记,由派生类维护
		int priorComplete;				//反序遍历尾部标记,由派生类维护
	public:
		//构造函数
		ThreadIterator(BiTrThNode<T> *tree);

		//算法需要的成员函数
		virtual void First(void) = 0;					//纯虚函数
		virtual void Last(void) = 0;					//纯虚函数
		virtual void Prior(void) = 0;					//纯虚函数
		virtual void Next(void) = 0;					//纯虚函数
		virtual int EndOfNext(void)const
			{return nextComplete;}
		virtual int EndOfPrior(void)const
			{return priorComplete;}

		//数据检索和修改成员函数
		T& Data(void);						
};

template <class T>
ThreadIterator<T>::ThreadIterator(BiTrThNode<T> *tree)
{
	root = tree;
	current = root;
	if(tree == NULL)
	{
		nextComplete = 1;
		priorComplete = 1;
	}
	else 
	{
		nextComplete = 0;
		priorComplete = 0;
	}
}

template <class T>
T& ThreadIterator<T>::Data(void)
{
	if(root == NULL)
	{
		cout << "二叉树空!" << endl;
		exit(1);
	}
	return current->data;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -