Skip to content
Snippets Groups Projects
Commit 2fa6ae6f authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: use pre-increment and cbegin/cend form for forAll* macros

- no reason to use post-increment in forAll() macro.

- use C++11 cbegin()/cend() method names for forAll*Iter() macros.
  These method names have been in OpenFOAM since 2009 and are also
  used by C++11 containers.

STYLE: nullptr instead of 0 in UList
parent fe0bb227
No related branches found
No related tags found
No related merge requests found
...@@ -427,7 +427,7 @@ inline void reverse(UList<T>&); ...@@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
// \endcode // \endcode
// \sa forAllReverse // \sa forAllReverse
#define forAll(list, i) \ #define forAll(list, i) \
for (Foam::label i=0; i<(list).size(); i++) for (Foam::label i=0; i<(list).size(); ++i)
//- Reverse loop across all elements in \a list //- Reverse loop across all elements in \a list
// \par Usage // \par Usage
...@@ -439,7 +439,7 @@ inline void reverse(UList<T>&); ...@@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
// \endcode // \endcode
// \sa forAll // \sa forAll
#define forAllReverse(list, i) \ #define forAllReverse(list, i) \
for (Foam::label i=(list).size()-1; i>=0; i--) for (Foam::label i=(list).size()-1; i>=0; --i)
//- Iterate across all elements in the \a container object of type //- Iterate across all elements in the \a container object of type
// \a Container. // \a Container.
...@@ -472,8 +472,8 @@ inline void reverse(UList<T>&); ...@@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
#define forAllConstIter(Container,container,iter) \ #define forAllConstIter(Container,container,iter) \
for \ for \
( \ ( \
Container::const_iterator iter = (container).begin(); \ Container::const_iterator iter = (container).cbegin(); \
iter != (container).end(); \ iter != (container).cend(); \
++iter \ ++iter \
) )
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -33,7 +33,7 @@ template<class T> ...@@ -33,7 +33,7 @@ template<class T>
inline Foam::UList<T>::UList() inline Foam::UList<T>::UList()
: :
size_(0), size_(0),
v_(0) v_(nullptr)
{} {}
...@@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const ...@@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
template<class T> template<class T>
inline void Foam::reverse(UList<T>& ul, const label n) inline void Foam::reverse(UList<T>& ul, const label n)
{ {
for (int i=0; i<n/2; i++) for (int i=0; i<n/2; ++i)
{ {
Swap(ul[i], ul[n-1-i]); Swap(ul[i], ul[n-1-i]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment