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


C++ Cells::begin方法代码示例

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


在下文中一共展示了Cells::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isWithinDistanceOfAnything

// The strategy here is, though this is n^2, it's a very small n, just
// finely-spaced adjacent cells.
bool SpatialHash::isWithinDistanceOfAnything(PointType const& physPt,
                                             double distance) const
{
   // (save taking a lot of square roots)
   double d2 = distance * distance;

   Index idx = index_of(physPt);
   Cells nbrs;
   get_neighbors(idx, nbrs);
   // 27 <= we include the center cell itself, too.
   assert(nbrs.size() <= 27);
   for (Cells::const_iterator itCells = nbrs.begin(), endCells = nbrs.end();
        itCells != endCells; ++itCells) {
      Pts const* pts = *itCells;
      if (pts) {
         for (Pts::const_iterator itPts = pts->begin(), endPts = pts->end();
              itPts != endPts; ++itPts) {
            if (itPts->SquaredEuclideanDistanceTo<double>(physPt) < d2) {
               return true;
            }
         }
      }
   }
   return false;
}
开发者ID:JDonner,项目名称:gabbleduck,代码行数:27,代码来源:spatial-hash.cpp

示例2: evolve

void GolPattern::evolve( )
{
    Cells maybes;
    // Update adjacence
    for( Cells::iterator it = mAlives.begin(); it != mAlives.end(); ++it )
    {
        for( int i = 0; i < 8; ++i )
        {
            Vecteur2i c = it->first + deltaPosAround[i];
            if( mAlives.find( c ) != mAlives.end() )
            {
                ++it->second;
            }
            else
            {
                // update maybes
                Cells::iterator it2 = maybes.find( c );
                if( it2 == maybes.end() )
                {
                    maybes[c] = 1;
                }
                else
                {
                    ++it2->second;
                }
            }
        }
    }

    // kill cells
    for( Cells::iterator it = mAlives.begin(); it != mAlives.end(); /* no increment */ )
    {
        const int adj = it->second;
        if( (unsigned int)( adj - 2 ) > 1 ) // only if adj is 2 or 3
        {
            mAlives.erase( it++ );
        }
        else
        {
            // reset
            it->second = 0;
            ++it;
        }
    }

    // resume life
    for( Cells::const_iterator it = maybes.begin(); it != maybes.end(); ++it )
    {
        const int adj = it->second;
        if( adj == 3 ) // only if adj is 3
        {
            mAlives[it->first] = 0;
        }
    }
    maybes.clear();
}
开发者ID:mathieumg,项目名称:hockedu,代码行数:56,代码来源:GolPattern.cpp

示例3: operator

    void operator()(Cells &cells, const Board &board, CellState color, const Eval &eval) noexcept {
        std::array<i64, 64> order;
        auto nextColor = switchCellState(color);
        for (const auto &cell : cells) {
            auto nextBoard = board;
            nextBoard.putStone(color, cell);
            order[cell.toInt()] = nextBoard.getReversibleCount(nextColor);
        }

        std::sort(cells.begin(), cells.end(),
            [order](const CellType &cell1, const CellType &cell2) {
            return order[cell1.toInt()] < order[cell2.toInt()];
        });
    }
开发者ID:odanado,项目名称:crosswalk,代码行数:14,代码来源:EndGameAI.hpp

示例4: regiterBlockedCells

void ConcreteProblem::regiterBlockedCells(const Cells& blockedCells) {
    for (CellPtrs::iterator cPtrIter = m_freeCellPtrs.begin(); cPtrIter != m_freeCellPtrs.end();) {
        bool blocked = false;
        CellPtr cellPtr = *cPtrIter;
        for (Cells::const_iterator cIter = blockedCells.begin(); cIter != blockedCells.end(); cIter++) {
            if (cellPtr->row == cIter->row && cellPtr->column == cIter->column) {
                blocked = true;
            }
        }
        if (blocked) {
            cPtrIter = m_freeCellPtrs.erase(cPtrIter);
        }
        else {
            cPtrIter++;
        }
    }
}
开发者ID:wws2003,项目名称:StudyProjectL2,代码行数:17,代码来源:ConcreteProblem.cpp


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