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


C++ ListBox::unlink方法代码示例

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


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

示例1:

// Cons lists
static Box *op_cons(ListBox *args)
{
    ListBox *ret = 0;

    for (ListBox *b = args; !b->isEmpty(); b = b->tail())
    {
	Box *box = b->head();

	if (!box->isListBox())
	{
	    VSLLib::eval_error("invalid argument -- argument is list");
	    if (ret)
		ret->unlink();
	    return 0;
	}

	if (!((ListBox *)box)->isEmpty())
	{
	    // Create list to append
	    // If box is last arg, a link suffices
	    ListBox *box2;
	    if (b->tail()->isEmpty())
		box2 = (ListBox *)box->link();
	    else
		box2 = (ListBox *)box->dup();

	    // Append list: 
	    // If box is first arg, copy box
	    if (ret == 0)
		ret = box2;
	    else
	    {
		ret->cons(box2);
		box2->unlink();
	    }
	}
    }

    // No args? return []
    if (ret == 0)
	ret = new ListBox;

    return ret;
}
开发者ID:aidanfarrow,项目名称:GC_tidy,代码行数:45,代码来源:VSLBuiltin.C

示例2: main


//.........这里部分代码省略.........
        {
            std::cout << argv[0] << ": usage: " << argv[0] << " [options] "
                      << "VSLLIB [THEMES...]\n\n" << VSEFlags::explain();

            exit(EXIT_FAILURE);
        }
    }

    // Create pic in THEBOX
    {
        // Read library
        long starttime = clock();
        ThemedVSLLib lib(library_file, VSEFlags::optimize_mode());
        long endtime = clock();

        assert(lib.OK());

        if (VSEFlags::show_optimizing_time)
            std::cout << "\nRead & optimizing time: "
                      << (endtime - starttime) / 1000 << " ms\n";

        // Build themes
        StringArray themes;
        for (int i = 2; i < argc; i++)
            themes += argv[i];
        lib.set_theme_list(themes);
        assert(lib.OK());

        if (VSEFlags::assert_library_ok)
            assert(lib.OK());

        if (VSEFlags::dump_library)
            std::cout << lib;

        if (VSEFlags::dump_tree)
            lib.dumpTree(std::cout);

        if (VSEFlags::suppress_eval)
            return EXIT_SUCCESS;

        // Fetch last function def (typically "main")
        VSLDef *def = lib.lastdef();

        if (def == 0)
        {
            std::cerr << argv[0] << ": cannot find last definition (sorry)\n";
            return EXIT_FAILURE;
        }

        // Eval function
        ListBox *arg = vsl_args(argc, argv);

        starttime = clock();
        for (int loop = 1; loop < VSEFlags::loops; loop++)
        {
            Box *result = (Box *)def->eval(arg);
            lib.output(result);
            result->unlink();
        }
        Box *result = (Box *)def->eval(arg);
        lib.output(result);
        endtime = clock();
        arg->unlink();

        // Show eval time
        if (VSEFlags::show_eval_time)
            std::cout << "\nEvaluation time: "
                      << (endtime - starttime) / 1000 << " ms\n";

        if (result && VSEFlags::dump_picture)
            std::cout << "#!" << argv[0] << "\n#include <std.vsl>\n\nmain() -> "
                      << *result << ";\n";

        thebox = result;

        // Stack and library are destroyed upon leaving this block
    }

    if (thebox && !thebox->size().isValid())
    {
        std::cerr << argv[0] << ": result has no size (maybe list?)\n";
        thebox->unlink();
        thebox = 0;
    }

    if (thebox == 0)
    {
        std::cerr << argv[0] << ": evaluation failed (sorry)\n";
        return EXIT_FAILURE;
    }

    // Realize Widget
    XtRealizeWidget(toplevel);

    // Process events
    XtAppMainLoop(app_con);

    // Never reached...
    return EXIT_SUCCESS;
}
开发者ID:sampost,项目名称:ddd,代码行数:101,代码来源:vsl.C


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