本文整理汇总了C++中Link::findForNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::findForNum方法的具体用法?C++ Link::findForNum怎么用?C++ Link::findForNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::findForNum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prim
Link* prim(Link *input, int p) {
bool first = true, cn = false;
int minW, num = 0, lnum = 0;
vector<int> points;
Link
*start = input->copyList()->getFirst(),
*start_t,
*end,
*end_t;
points.push_back(start->getX());
while (!isAll(points, p)) {
minW = start->maxW();
start_t = start;
while (start_t != NULL) {
if
(
(
(
count(points.begin(), points.end(), start_t->getX())
+
count(points.begin(), points.end(), start_t->getY())
)
== 1
)
&&
(
minW >= start_t->getW()
)
) {
minW = start_t->getW();
num = start_t->getN();
}
start_t = start_t->getNext();
}
if (lnum == num) {
for(int i = 1; i <= p; i++) {
if(!count(points.begin(), points.end(), i)) {
points.push_back(i);
cn = true;
break;
}
}
}
if (cn) {
cn = false;
continue;
}
lnum = num;
if (first) {
end = new Link(start->findForNum(num));
end_t = end;
end_t->setNext(NULL);
end_t->setPrev(NULL);
first = false;
} else {
end_t->addNewLink(start->findForNum(num));
end_t = end_t->getNext();
}
if (!count(points.begin(), points.end(), end_t->getX())) {
points.push_back(end_t->getX());
}
if (!count(points.begin(), points.end(), end_t->getY())) {
points.push_back(end_t->getY());
}
}
return end;
}