本文整理汇总了C++中Cells::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Cells::find方法的具体用法?C++ Cells::find怎么用?C++ Cells::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cells
的用法示例。
在下文中一共展示了Cells::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: c
std::set<Cell> tileCells (const nm::MapMetaData& info, const float d,
const Pred& pred)
{
ROS_DEBUG_NAMED ("tile", "Tiling %ux%u map", info.height, info.width);
Cells cells;
Cells forbidden;
int rad = ceil(d/info.resolution);
for (size_t x=0; x<info.width; x++)
{
for (size_t y=0; y<info.height; y++)
{
const Cell c(x, y);
if (!pred(c))
continue;
ROS_DEBUG_STREAM_NAMED("tile", "Cell " << c << " satisfies condition");
if (forbidden.find(c)!=forbidden.end())
continue;
ROS_DEBUG_STREAM_NAMED ("tile", " Sufficiently far");
cells.insert(c);
ROS_DEBUG_STREAM_NAMED ("tile", " Inserted");
for (int dx=0; dx<=rad; dx++)
{
for (int dy=-rad; dy<=rad; dy++)
{
const Cell c2(int(x)+dx, int(y)+dy);
if (dx*dx+dy*dy <= rad*rad && withinBounds(info, c2))
{
ROS_DEBUG_STREAM_NAMED ("tile", " Blocking " << c2);
forbidden.insert(c2);
}
}
}
}
}
ROS_DEBUG_NAMED("tile", "Done tiling");
return cells;
}