本文整理汇总了C++中AvlTree::inorderTraverse方法的典型用法代码示例。如果您正苦于以下问题:C++ AvlTree::inorderTraverse方法的具体用法?C++ AvlTree::inorderTraverse怎么用?C++ AvlTree::inorderTraverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AvlTree
的用法示例。
在下文中一共展示了AvlTree::inorderTraverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
AvlTree<Soundtrack> avlTree;
vector<Soundtrack> cdVector; // Holds soundtrack objects created from file input
string fileName = "Topic F Soundtrack.txt"; // File to open
bool ableToOpen; // Test success of opening file
cout << "Create and populate AVL tree\n\n";
do {
ableToOpen = openFile(fileName, cdVector, avlTree);
if (!ableToOpen)
{
cout << fileName << " cannot be opened. Enter another file name --> ";
getline(cin, fileName);
}
} while (!ableToOpen);
continueProgram();
cout << "Get item with key \"FSMBox 03 Disc 8\":\n\n";
Soundtrack FSM;
FSM.setLabel("FSM");
FSM.setCatalogNumber("Box 03 Disc 8");
if ( !avlTree.get(FSM) )
cout << "No items found with key \"FSMBox 03 Disc 8\"\n\n";
cout << "\n\nGet item with key \"FSMBox 07 Disc 8\":\n\n";
Soundtrack FSM2;
FSM2.setLabel("FSM");
FSM2.setCatalogNumber("Box 07 Disc 8");
if (!avlTree.get(FSM2))
cout << "No items found with key \"FSMBox 07 Disc 8\"\n";
continueProgram();
cout << "Listing of all items in the tree: (There are " << avlTree.getNumberOfNodes() << " items in the tree)\n\n";
avlTree.inorderTraverse(display);
continueProgram();
cout << "\n\nList all soundtracks recorded in the 1950s:\n\n";
vector<Soundtrack> matchedYear;
getYear(cdVector, matchedYear);
for (unsigned int i = 0; i < matchedYear.size(); i++)
{
if (avlTree.get(matchedYear[i]))
cout << matchedYear[i];
}
continueProgram();
cout << "\n\nDelete all items with key \"FSM V8N11\":";
Soundtrack dltFSM;
dltFSM.setLabel("FSM");
dltFSM.setCatalogNumber("V8N11");
if (avlTree.get(dltFSM))
{
avlTree.remove(dltFSM);
cout << dltFSM << "\nhas been deleted\n\n";
}
cout << "Again delete all items with key \"FSM V8N11\":\n";
if (avlTree.get(dltFSM))
{
avlTree.remove(dltFSM);
cout << dltFSM << "\nhas been deleted\n\n";
}
else
cout << "NO items for \"FSM V8N11\"";
continueProgram();
cout << "\nListing of all items in the tree: (There are " << avlTree.getNumberOfNodes() << " items in the tree)\n";
avlTree.inorderTraverse(display);
cin.ignore( cin.rdbuf()->in_avail() );
cout << "\n\nProgram Ending\n\n";
cout << "Press Enter to end --> ";
cin.ignore();
} // end main