本文整理汇总了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;
}
示例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();
}
示例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()];
});
}
示例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++;
}
}
}