summaryrefslogtreecommitdiff
path: root/slideshow/source/inc
diff options
context:
space:
mode:
authorDaniel Robertson <danlrobertson89@gmail.com>2015-10-09 09:21:20 -0400
committerNoel Grandin <noelgrandin@gmail.com>2015-10-11 06:13:15 +0000
commitb6297280853a7325ac0fa226b783652b22daebd0 (patch)
tree776739246232bc937d913d019841e3902423ed78 /slideshow/source/inc
parent143fb0a4b5d4ab69d4928299d8112ab95d99870a (diff)
Replace simple while loops with range-based for
Replace simple while loops with range-based for-loops when apropriate. There should be no side effects due to this change. Change-Id: I0c39d4c10c991354248e864a09333144974c953c Reviewed-on: https://gerrit.libreoffice.org/19281 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'slideshow/source/inc')
-rw-r--r--slideshow/source/inc/listenercontainer.hxx34
1 files changed, 9 insertions, 25 deletions
diff --git a/slideshow/source/inc/listenercontainer.hxx b/slideshow/source/inc/listenercontainer.hxx
index 8317ac97f258..4d45dbaf8f2d 100644
--- a/slideshow/source/inc/listenercontainer.hxx
+++ b/slideshow/source/inc/listenercontainer.hxx
@@ -102,19 +102,15 @@ template< typename ListenerT > struct ListenerOperations
FuncT func )
{
bool bRet(false);
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
if( FunctionApply< typename FuncT::result_type,
typename ContainerT::value_type >::apply(
func,
- *aCurr) )
+ rCurr) )
{
bRet = true;
}
-
- ++aCurr;
}
// true: at least one handler returned true
@@ -137,16 +133,12 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
static bool notifySingleListener( ContainerT& rContainer,
FuncT func )
{
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
- boost::shared_ptr<ListenerTargetT> pListener( aCurr->lock() );
+ boost::shared_ptr<ListenerTargetT> pListener( rCurr.lock() );
if( pListener && func(pListener) )
return true;
-
- ++aCurr;
}
return false;
@@ -158,11 +150,9 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
FuncT func )
{
bool bRet(false);
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
- boost::shared_ptr<ListenerTargetT> pListener( aCurr->lock() );
+ boost::shared_ptr<ListenerTargetT> pListener( rCurr.lock() );
if( pListener.get() &&
FunctionApply< typename FuncT::result_type,
@@ -170,8 +160,6 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
{
bRet = true;
}
-
- ++aCurr;
}
return bRet;
@@ -186,14 +174,10 @@ struct ListenerOperations< boost::weak_ptr<ListenerTargetT> >
ContainerT aAliveListeners;
aAliveListeners.reserve(rContainer.size());
- typename ContainerT::const_iterator aCurr( rContainer.begin() );
- typename ContainerT::const_iterator const aEnd ( rContainer.end() );
- while( aCurr != aEnd )
+ for( const auto& rCurr : rContainer )
{
- if( !aCurr->expired() )
- aAliveListeners.push_back( *aCurr );
-
- ++aCurr;
+ if( !rCurr.expired() )
+ aAliveListeners.push_back( rCurr );
}
std::swap( rContainer, aAliveListeners );