本文整理汇总了C++中QValueList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueList::insert方法的具体用法?C++ QValueList::insert怎么用?C++ QValueList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueList
的用法示例。
在下文中一共展示了QValueList::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sortedVersionList
/**
* Return a list of PackageVersion objects sorted by their version numbers,
* with the oldest version at the beginning and the latest version at the end
* of the list.
*/
QValueList<PackageVersion*> Package::sortedVersionList()
{
QValueList<PackageVersion*> sortedVersions;
QValueList<PackageVersion*>::iterator sortedVersionIterator;
PackageVersionMap::iterator versionIterator;
for( versionIterator = m_versions.begin();
versionIterator != m_versions.end(); versionIterator++ )
{
if( versionIterator == m_versions.begin() ) {
sortedVersions.append( *versionIterator );
continue; // if there is only one version, it can't be compared
}
// reverse iteration through the sorted version list
sortedVersionIterator = sortedVersions.end();
while( true )
{
if( sortedVersionIterator == sortedVersions.begin() )
{
sortedVersions.prepend( *versionIterator );
break;
}
sortedVersionIterator--;
if( (*versionIterator)->isNewerThan(
(*sortedVersionIterator)->version() ) )
{
sortedVersionIterator++; // insert after the compared one, not before
sortedVersions.insert( sortedVersionIterator, *versionIterator );
break;
}
}
}
return sortedVersions;
} // end of sortedVersionList()