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
......@@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
// \endcode
// \sa forAllReverse
#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
// \par Usage
......@@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
// \endcode
// \sa forAll
#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
// \a Container.
......@@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
#define forAllConstIter(Container,container,iter) \
for \
( \
Container::const_iterator iter = (container).begin(); \
iter != (container).end(); \
Container::const_iterator iter = (container).cbegin(); \
iter != (container).cend(); \
++iter \
)
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -33,7 +33,7 @@ template<class T>
inline Foam::UList<T>::UList()
:
size_(0),
v_(0)
v_(nullptr)
{}
......@@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
template<class T>
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]);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment