本文整理汇总了C++中ListType::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ListType::empty方法的具体用法?C++ ListType::empty怎么用?C++ ListType::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListType
的用法示例。
在下文中一共展示了ListType::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: randomFragment
inline typename ListType::Iterator randomFragment(const ListType& src)
{
if( src.empty() ) return src.end();
typename ListType::ConstIterator result = src.begin();
::std::advance( result, ::std::rand() % src.size() );
return result;
}
示例2: FragmentType
typename ListType::FragmentType
selectBlock(const ListType& src, typename ListType::FSizeType blockSize,
const AvailableType* available )
{
typedef typename ListType::FragmentType FragmentType;
typedef typename ListType::FSizeType FSizeType;
typedef typename ListType::ConstIterator ConstIterator;
if( src.empty() ) return FragmentType( 0,
::std::numeric_limits< FSizeType >::max() );
::std::deque< FSizeType > blocks;
for( ConstIterator selectIterator = src.begin();
selectIterator != src.end(); ++selectIterator )
{
FSizeType blockBegin = selectIterator->begin() / blockSize;
FSizeType blockEnd = ( selectIterator->end() - 1 ) / blockSize;
if ( selectIterator->begin() % blockSize )
{
// the start of a block is complete, but part is missing
if ( !available || available[ blockBegin ] )
{
return FragmentType( selectIterator->begin(),
::std::min( selectIterator->end(),
blockSize * ( blockBegin + 1 ) ) );
}
++blockBegin;
}
if ( blockBegin <= blockEnd && selectIterator->end() % blockSize
&& selectIterator->end() < src.limit() )
{
// the end of a block is complete, but part is missing
if ( !available || available[ blockEnd ] )
{
return FragmentType( blockEnd * blockSize,
selectIterator->end() );
}
--blockEnd;
}
// this fragment contains one or more aligned empty blocks
if( blockEnd != ~0ULL ) for( ; blockBegin <= blockEnd; ++blockBegin )
{
if( !available || available[ blockBegin ] )
{
blocks.push_back( blockBegin );
}
}
}
if( blocks.empty() ) return FragmentType( 0,
::std::numeric_limits< FSizeType >::max() );
FSizeType blockBegin = blocks[ ::std::rand() % blocks.size() ] * blockSize;
return FragmentType( blockBegin, ::std::min( blockBegin + blockSize, src.limit() ) );
}