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


C++ Nodes::clear方法代码示例

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


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

示例1: neighbors

static void neighbors(Node *n, Nodes &r, NodePool &p, const Grid &g) {
  Tile v[16];
  size_t s = g.adjacent(n->tile, v, COUNTOF(v));
  r.clear();
  for (Tile *t = v; t < v + s; ++t) {
    float c = g.get(*t);
    if (c > 0.1f) {
      Node *a = new (p) Node(*t, c);
      r.push_back(a);
    }
  }
}
开发者ID:coleminor,项目名称:el-misc-tools,代码行数:12,代码来源:path.cpp

示例2: main

int main()
{
    Nodes nodes;
    Neighbors neighbors;

    int n = 0, edges = 0, index = 0, nodeX = 0, nodeY = 0;

    while (true)
    {
        cin >> n;

        if (!n)
        {
            break;
        }

        nodes.clear();
        neighbors.clear();

        for (index = 0; index < n; index++)
        {
            nodes[index] = Uncolored;
        }
        
        cin >> edges;

        while (edges)
        {
            cin >> nodeX >> nodeY;

            neighbors[nodeX].push_back(nodeY);
            neighbors[nodeY].push_back(nodeX);

            edges--;
        }

        cout << (Colorable(nodes, neighbors)? "BICOLORABLE." : "NOT BICOLORABLE.") << endl;
    }
    return 0;
}
开发者ID:skalyanasundaram,项目名称:BrainTuners,代码行数:40,代码来源:10004-BiColoring.cpp

示例3: subst_macros

void Evaluator::subst_macros()
{
    int cntr = 0;
    Token gtok(0, 0);
    while (1)
    {
        if (++cntr > MAX_SUBST)
            throw Err("Too many macro substitutions: " + bug::to_string(MAX_SUBST) + ", possible recursion", gtok);

        bool weresubs = false;

        Nodes old = root->children;
        root->children.clear();

        Nodes leftovers;
        for (auto i : old)
        {
            Instruction * pin = get<Instruction>(NOTHR, i);
            if (pin)
            {
                for (auto j : leftovers)
                    i->children[0]->children[1]->children.push_back(j);

                leftovers.clear();

                root->addChild(i);
                continue;
            }

            Macuse * u = get<Macuse>(LNFUN, i);
            gtok = u->tok();

            if (u->name() == "@end")
            {
                for (auto j : u->children[0]->children)
                    leftovers.push_back(j);
                continue;
            }

            Nodes inject = Macros(root).process_macuse(*u);

            if (!inject.empty())
            {
                Pnode pn = inject.front();
                Instruction * pin = get<Instruction>(NOTHR, pn);
                if (pin)
                {
                    for (auto j : leftovers)
                        pn->children[0]->children[1]->children.push_back(j);
                }
                else
                {
                    Macuse * pu = get<Macuse>(LNFUN, pn);
                    for (auto j : leftovers)
                        pu->children[0]->children.push_back(j);
                }

                leftovers.clear();
            }

            for (auto j : inject)
                root->addChild(j);

            weresubs = true;
        }

        if (!weresubs)
        {
            if (leftovers.empty())
                break;

            if (root->children.empty())
                throw Err("Labels used in empty program");

            throw Err("Program finishes with label (see macro definition)", root->children.back()->tok());
        }
        // this can be improved later (one extra loop)
        // when expanding macro we can detect that no new macro introduced
    } // while
}
开发者ID:hoangt,项目名称:cryptoleq,代码行数:80,代码来源:evltor.cpp


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