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


C++ AvlTree::getNumberOfNodes方法代码示例

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


在下文中一共展示了AvlTree::getNumberOfNodes方法的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
开发者ID:Jeff457,项目名称:M20-Topic-F,代码行数:79,代码来源:TopicF.cpp


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