[partition] Using std::find_if to search in container for elements according to a condition

main
Caio Carvalho 6 years ago
parent 34e091833d
commit 2c33535ee8

@ -551,26 +551,22 @@ PartitionCoreModule::lvmPVs() const
bool bool
PartitionCoreModule::hasVGwithThisName( const QString& name ) const PartitionCoreModule::hasVGwithThisName( const QString& name ) const
{ {
for ( DeviceInfo* d : m_deviceInfos ) auto condition = [ name ]( DeviceInfo* d ) {
if ( dynamic_cast<LvmDevice*>(d->device.data()) && return dynamic_cast<LvmDevice*>(d->device.data()) && d->device.data()->name() == name;
d->device.data()->name() == name) };
return true;
return false; return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
} }
bool bool
PartitionCoreModule::isInVG( const Partition *partition ) const PartitionCoreModule::isInVG( const Partition *partition ) const
{ {
for ( DeviceInfo* d : m_deviceInfos ) auto condition = [ partition ]( DeviceInfo* d ) {
{ LvmDevice* vg = dynamic_cast<LvmDevice*>( d->device.data());
LvmDevice* vg = dynamic_cast<LvmDevice*>( d->device.data() ); return vg && vg->physicalVolumes().contains( partition );
};
if ( vg && vg->physicalVolumes().contains( partition )) return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
return true;
}
return false;
} }
void void

Loading…
Cancel
Save