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


C++ SymTab::Remove方法代码示例

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


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

示例1: main

int main (int argc, char * const * argv) {
        char buffer[BUFSIZ];
        char command;
        long number;
        char option;

        SymTab<UCSDStudent>::Set_Debug_Off ();

        while ((option = getopt (argc, argv, "x")) != EOF) {

        switch (option) {
                case 'x': SymTab<UCSDStudent>::Set_Debug_On ();
                        break;
                }
        }

        SymTab<UCSDStudent> ST;
        ST.Write (cout << "Initial Symbol Table:\n" );

        while (cin) {
                command = NULL;         // reset command each time in loop
                cout << "Please enter a command ((i)nsert, "
                        << "(l)ookup, (r)emove, (w)rite):  ";
                cin >> command;

                switch (command) {

                case 'i': {
                        cout << "Please enter UCSD student name to insert:  ";
                        cin >> buffer;  // formatted input

                        cout << "Please enter UCSD student number:  ";
                        cin >> number;

                        UCSDStudent stu (buffer, number);

                        // create student and place in symbol table
                        ST.Insert (stu);
                        break;
                }
                case 'l': {
                        unsigned long found;    // whether found or not

                        cout << "Please enter UCSD student name to lookup:  ";
                        cin >> buffer;  // formatted input

                        UCSDStudent stu (buffer, 0);
                        found = ST.Lookup (stu);

                        if (found)
                                cout << "Student found!!!\n" << stu << "\n";
                        else
                                cout << "student " << buffer << " not there!\n";
                        break;
                        }
                case 'r': {
                        unsigned long removed;

                        cout << "Please enter UCSD student name to remove:  ";
                        cin >> buffer;  // formatted input

                        UCSDStudent stu (buffer, 0);
                        removed = ST.Remove(stu);

                        if (removed)
                                cout << "Student removed!!!\n" << stu << "\n";
                        else
                                cout << "student " << buffer << " not there!\n";
                        break;
                }
                case 'w':
                        ST.Write (cout << "The Symbol Table contains:\n");
                }
        }

        ST.Write (cout << "\nFinal Symbol Table:\n");

}
开发者ID:Patchett,项目名称:Self-Balancing-BST,代码行数:78,代码来源:Driver.c


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