本文整理汇总了C++中BrowserNode::solve方法的典型用法代码示例。如果您正苦于以下问题:C++ BrowserNode::solve方法的具体用法?C++ BrowserNode::solve怎么用?C++ BrowserNode::solve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BrowserNode
的用法示例。
在下文中一共展示了BrowserNode::solve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
// solve state and return TRUE if Young
bool BrowserNode::solve()
{
if (state != Unknown)
return (state == Young);
// note : parent can't be 0
BrowserNode * p = (BrowserNode *) parent();
if ((p->state == Unknown) ? p->solve() : (p->state == Young)) {
state = Young;
return TRUE;
}
else {
state = Deleted;
return FALSE;
}
}
示例2: update
//.........这里部分代码省略.........
int rev = bn->get_rev();
Use * use = all_nodes.find(itd.key()).value();
if (use == 0)
all_nodes.insert(itd.key(), new Use(rev));
else {
if (rev < use->rev_min)
use->rev_min = rev;
if (rev > use->rev_max)
use->rev_max = rev;
use->count += 1;
}
}
}
// first solve step
// only the package existing in all the view are solved
int nviews = lv.count();
QStringList deleted_or_new;
QHash<QString, Use*>::iterator itu = all_nodes.begin();
for (; itu!=all_nodes.end(); ++itu) {
QString who = itu.key();
Use * use = itu.value();
if (use->count == nviews) {
// exist in all views : solve the state
if (use->rev_min == use->rev_max) {
// up to date in all views
itv = lv.begin();
for (; itv != lv.end(); ++itv)
(*itv)->nodes.find(who).value()->set_state(UpToDate);
}
else {
int max = use->rev_max;
itv = lv.begin();
for (; itv != lv.end(); ++itv) {
BrowserNode * pack = (*itv)->nodes.find(who).value();
pack->set_state((pack->get_rev() == max) ? Young : Old);
}
}
}
else {
// deleted or new, mark it unknown for this step
deleted_or_new.append(who);
itv = lv.begin();
for (; itv != lv.end(); ++itv) {
BrowserNode * pack = (*itv)->nodes.find(who).value();
if (pack != 0)
pack->set_state(Unknown);
}
}
}
itu = all_nodes.begin();
for (; itu!=all_nodes.end(); ++itu)
{
delete itu.value();
}
all_nodes.clear();
// solve packages marked unknown
// a package is deleted if its parent is never 'Young'
QStringList::Iterator it;
for (it = deleted_or_new.begin(); it != deleted_or_new.end(); ++it) {
QString who = *it;
QList<BrowserNode *> images;
bool young = FALSE;
// set the state in each view without looking at the others
itv = lv.begin();
for (; itv != lv.end(); ++itv) {
BrowserNode * pack = (*itv)->nodes.find(who).value();
if (pack != 0) {
images.append(pack);
if (pack->solve())
young = TRUE;
}
}
// set the final state if young, else all already marked deleted
if (young) {
;
foreach (BrowserNode * pack, images) {
pack->set_state(Young);
}
}
}
示例3: update
void BrowserView::update(const Q3PtrList<BrowserView> & lv)
{
Q3Dict<Use> all_nodes(DICT_SIZE);
Q3PtrListIterator<BrowserView> itv(lv);
all_nodes.setAutoDelete(TRUE);
// look at the revision in each view
for (; itv.current(); ++itv) {
Q3DictIterator<BrowserNode> itd(itv.current()->nodes);
for (; itd.current(); ++itd) {
BrowserNode * bn = itd.current();
int rev = bn->get_rev();
Use * use = all_nodes.find(itd.currentKey());
if (use == 0)
all_nodes.insert(itd.currentKey(), new Use(rev));
else {
if (rev < use->rev_min)
use->rev_min = rev;
if (rev > use->rev_max)
use->rev_max = rev;
use->count += 1;
}
}
}
// first solve step
// only the package existing in all the view are solved
int nviews = lv.count();
QStringList deleted_or_new;
Q3DictIterator<Use> itu(all_nodes);
for (; itu.current(); ++itu) {
QString who = itu.currentKey();
Use * use = itu.current();
if (use->count == nviews) {
// exist in all views : solve the state
if (use->rev_min == use->rev_max) {
// up to date in all views
for (itv.toFirst(); itv.current(); ++itv)
itv.current()->nodes.find(who)->set_state(UpToDate);
}
else {
int max = use->rev_max;
for (itv.toFirst(); itv.current(); ++itv) {
BrowserNode * pack = itv.current()->nodes.find(who);
pack->set_state((pack->get_rev() == max) ? Young : Old);
}
}
}
else {
// deleted or new, mark it unknown for this step
deleted_or_new.append(who);
for (itv.toFirst(); itv.current(); ++itv) {
BrowserNode * pack = itv.current()->nodes.find(who);
if (pack != 0)
pack->set_state(Unknown);
}
}
}
all_nodes.clear();
// solve packages marked unknown
// a package is deleted if its parent is never 'Young'
QStringList::Iterator it;
for (it = deleted_or_new.begin(); it != deleted_or_new.end(); ++it) {
QString who = *it;
Q3PtrList<BrowserNode> images;
bool young = FALSE;
// set the state in each view without looking at the others
for (itv.toFirst(); itv.current(); ++itv) {
BrowserNode * pack = itv.current()->nodes.find(who);
if (pack != 0) {
images.append(pack);
if (pack->solve())
young = TRUE;
}
}
// set the final state if young, else all already marked deleted
if (young) {
BrowserNode * pack;
for (pack = images.first(); pack != 0; pack = images.next())
pack->set_state(Young);
//.........这里部分代码省略.........