当前位置: 首页>>代码示例>>C++>>正文


C++ BNode::GetData方法代码示例

本文整理汇总了C++中BNode::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ BNode::GetData方法的具体用法?C++ BNode::GetData怎么用?C++ BNode::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BNode的用法示例。


在下文中一共展示了BNode::GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){

	BST testBST;
	BST testAssign;
	BNode* temp;
	int data;

	PrintMenu();
	cout << "-->";
	char choice;
	cin >> choice;

	while(choice != 'q' && choice != 'Q'){

		if (choice == '!'){
			BST testCopy(testBST);
			cout << "Result:" << "Print New Copy" << endl;
			testCopy.PrintIn(cout); cout << endl;
			testCopy.Insert(-10000);
			cout << "Result: " << "Print Modified Copy" << endl;
			testCopy.PrintIn(cout); cout << endl;
			cout << "Result: " << "Print Original Test List" << endl;
			testBST.PrintIn(cout); cout << endl;
		}
		else{
			switch (choice){
				case 'h':
				case 'H': PrintMenu(); break;
				case '+':
					cin >> data;
					testBST.Insert(data);
					break;
				case '-':
					cin >> data;
					testBST.Remove(data);
					break;

				case '@':
					cout <<"Result:";
					temp = testBST.AtCursor();
					if (temp)
						cout << temp->GetData() << endl;
					else
						cout << "NULL POINTER" << endl;
					break;
				case '<':
					testBST.GoToBeginning();
					break;
				case '>':
					testBST.GoToEnd();
					break;
				case 'n':
				case 'N':
					testBST.GoToNext();
					break;
				case 'p':
				case 'P':
					testBST.GoToPrev();
					break;
				case 'c':
				case 'C':
					testBST.ClearList();
					break;

				case 'e':
				case 'E':
					if (testBST.Empty())
						cout <<"Result:" <<  "List Is Empty" << endl;
					else
						cout <<"Result:" <<  "List is Not Empty" << endl;
					break;
				case '#':
					//assign list
					testAssign = testBST;
					testAssign.Insert(-100000);
					cout << "Modify New List" << endl;
					testAssign.PrintIn(cout); cout << endl;
					cout << "Old List should not be affected" << endl;
					testBST.PrintIn(cout); cout << endl;
					testAssign.~BST();
					cout << "Destroy New List" << endl;
					cout << "Old List should not be affected" << endl;
					testBST.PrintIn(cout); cout << endl;
					break;
				case '?':
					cin >> data;
					if (testBST.Find(data) != NULL)
						cout << "Result:" << data << "\tfound" << endl;
					else
						cout << "Result:" << data << "\tnot found" << endl;
					break;
				case 'i':
				case 'I':
					cout << "Print INORDER" << endl;
					testBST.PrintIn(cout); cout << endl;
					break;
				case 'r':
				case 'R':
					cout << "Print PREORDER" << endl;
					testBST.PrintPre(cout); cout << endl;
//.........这里部分代码省略.........
开发者ID:shapr,项目名称:bstcs355,代码行数:101,代码来源:BST_Driver.cpp


注:本文中的BNode::GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。