本文整理汇总了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);
}
}
}
示例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;
}
示例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
}