本文整理汇总了C++中std::list::getRight方法的典型用法代码示例。如果您正苦于以下问题:C++ list::getRight方法的具体用法?C++ list::getRight怎么用?C++ list::getRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::getRight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//Alt. version of reduceIdent()
Identity Graph::reduceIdent2(std::list<Identity>::iterator pid, std::list< std::list<Node>::iterator >& pidPath, bool report)
{
std::list<Node>::iterator prightNode;
prightNode = pid->getRight();
//use to trace back through pidPath
std::list< std::list<Node>::iterator >::reverse_iterator pleftPath = pidPath.rbegin();
std::list< std::list<Node>::iterator >::reverse_iterator pleftPathPlus1 = pleftPath;
pleftPathPlus1++;
while (pleftPathPlus1 != pidPath.rend())
{
//look for pleft in pleftPlus1's xout list
if ((*pleftPathPlus1)->isInXout(*pleftPath))
{
if (prightNode->isXinEmpty())
break;
prightNode = prightNode->getXin();
} //look in pleftPlus1's yout list
else if ((*pleftPathPlus1)->isInYout(*pleftPath))
{
if (prightNode->isYinEmpty())
break;
prightNode = prightNode->getYin();
}
else //in this case the path is not valid
{
std::cout << "\nBAD PATH FOR IDENTITY:\n";
pid->printIdent();
Identity nullid;
return nullid;
}
pleftPath++;
pleftPathPlus1++;
}
//make and return reduced identity;
Identity reducedId(*pleftPath, prightNode, pid->getBase());
if (report)
{
std::cout << "\nIdentity ";
pid->printIdent();
std::cout << "\nreduced to ";
reducedId.printIdent();
std::cout << "\n";
}
return reducedId;
}
示例2: reduceIdent
//Reduce and return identity
Identity Graph::reduceIdent(std::list<Identity>::iterator pid)
{
std::list<Node>::iterator pleftNode, prightNode, pbaseNode;
pleftNode = pid->getLeft();
prightNode = pid->getRight();
pbaseNode = pid->getBase();
std::vector<short> leftWord = pleftNode->getElemName();
std::vector<short> baseWord = pbaseNode->getElemName();
bool letterSwitch = pleftNode->lastLetterIsX(); //x <-> true, y <-> false
bool endPath = false; //detect if right reduction has reached an empty product
while (leftWord.size() != baseWord.size()) //loop over exponents until last exp. of baseWord
{
while (leftWord[leftWord.size() - 1] > 0)
{
//check right path; if exists, move left and right back one product
if (letterSwitch) //for letter x
{
if (!prightNode->isXinEmpty())
{
prightNode = prightNode->getXin();
pleftNode = pleftNode->getXin();
/*
///Test: use search instead of pointers
std::vector<short> searchWord = leftWord;
searchWord[leftWord.size() - 1] = leftWord[leftWord.size() - 1] - 1;
if (searchWord[leftWord.size() - 1] == 0)
searchWord.pop_back();
pleftNode = searchNodes(&searchWord);
///Test
*/
}
else
{
endPath = true;
break;
}
}
else //for letter y
{
if (!prightNode->isYinEmpty())
{
prightNode = prightNode->getYin();
pleftNode = pleftNode->getYin();
/*
///Test: use search instead of pointers
std::vector<short> searchWord = leftWord;
searchWord[leftWord.size() - 1] = leftWord[leftWord.size() - 1] - 1;
if (searchWord[leftWord.size() - 1] == 0)
searchWord.pop_back();
pleftNode = searchNodes(&searchWord);
///Test
*/
}
else
{
endPath = true;
break;
}
}
//decrement last exponent
leftWord[leftWord.size() - 1] = leftWord[leftWord.size() - 1] - 1;
}
//either loop broken prematurely by end of path...
if (endPath)
break;
//...or exponent is now 0, so move to next exponent
leftWord.pop_back();
letterSwitch = !letterSwitch;
}
//if not at end of path, continue reducing
if (!endPath)
{
while (baseWord[baseWord.size() - 1] != leftWord[leftWord.size() - 1])
{
if (letterSwitch)
{
if (!prightNode->isXinEmpty())
{
prightNode = prightNode->getXin();
pleftNode = pleftNode->getXin();
/*
///Test: use search instead of pointers
std::vector<short> searchWord = leftWord;
searchWord[leftWord.size() - 1] = leftWord[leftWord.size() - 1] - 1;
if (searchWord[leftWord.size() - 1] == 0)
searchWord.pop_back();
pleftNode = searchNodes(&searchWord);
///Test
*/
}
else
{
endPath = true;
//.........这里部分代码省略.........