本文整理汇总了C++中std::list::processing_speed方法的典型用法代码示例。如果您正苦于以下问题:C++ list::processing_speed方法的具体用法?C++ list::processing_speed怎么用?C++ list::processing_speed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::processing_speed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void active_item_cache::add( std::list<item>::iterator it, point location )
{
if( has( it, location ) ) {
return;
}
active_items[it->processing_speed()].push_back( item_reference{ location, it, &*it } );
active_item_set[ &*it ] = false;
}
示例2: remove
void active_item_cache::remove( std::list<item>::iterator it, point location )
{
const auto predicate = [&]( const item_reference & active_item ) {
return location == active_item.location && active_item.item_iterator == it;
};
// The iterator is expected to be in this list, as it was added that way in `add`.
// But the processing_speed may have changed, so if it's not in the expected container,
// remove it from all containers to ensure no stale iterator remains.
auto &expected = active_items[it->processing_speed()];
const auto iter = std::find_if( expected.begin(), expected.end(), predicate );
if( iter != expected.end() ) {
expected.erase( iter );
} else {
for( auto &e : active_items ) {
e.second.remove_if( predicate );
}
}
if( active_item_set.erase( &*it ) == 0 ) {
// map erase returns number of elements erased
debugmsg( "The item isn't there!" );
}
}