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


C++ list::getBase方法代码示例

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


在下文中一共展示了list::getBase方法的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;
}
开发者ID:clamheart,项目名称:BGG,代码行数:52,代码来源:graph3.cpp

示例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;
//.........这里部分代码省略.........
开发者ID:clamheart,项目名称:BGG,代码行数:101,代码来源:graph3.cpp


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