mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: minor code adjustments
- constness on local variables, pre-increment on loops, parameter names
This commit is contained in:
@ -47,10 +47,10 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
|
||||
const char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
|
||||
|
||||
if (s)
|
||||
{
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(Istream& is, const label size)
|
||||
{
|
||||
table_ = new hashedEntry*[tableSize_];
|
||||
|
||||
for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++)
|
||||
for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
|
||||
{
|
||||
table_[hashIdx] = 0;
|
||||
}
|
||||
@ -116,10 +116,10 @@ Foam::Istream& Foam::operator>>
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("HashTable<T, Key, Hash>");
|
||||
const char delimiter = is.readBeginList("HashTable<T, Key, Hash>");
|
||||
|
||||
if (s)
|
||||
{
|
||||
@ -130,7 +130,7 @@ Foam::Istream& Foam::operator>>
|
||||
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
Key key;
|
||||
is >> key;
|
||||
|
||||
@ -44,10 +44,10 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("ILList<LListBase, T>");
|
||||
const char delimiter = is.readBeginList("ILList<LListBase, T>");
|
||||
|
||||
if (s)
|
||||
{
|
||||
|
||||
@ -55,10 +55,10 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("LList<LListBase, T>");
|
||||
const char delimiter = is.readBeginList("LList<LListBase, T>");
|
||||
|
||||
if (s)
|
||||
{
|
||||
|
||||
@ -49,10 +49,10 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("LPtrList<LListBase, T>");
|
||||
const char delimiter = is.readBeginList("LPtrList<LListBase, T>");
|
||||
|
||||
if (s)
|
||||
{
|
||||
|
||||
@ -125,7 +125,7 @@ public:
|
||||
inline FixedList();
|
||||
|
||||
//- Construct from value
|
||||
explicit inline FixedList(const T&);
|
||||
explicit inline FixedList(const T& t);
|
||||
|
||||
//- Construct from C-array
|
||||
explicit inline FixedList(const T v[Size]);
|
||||
@ -135,19 +135,19 @@ public:
|
||||
inline FixedList(InputIterator first, InputIterator last);
|
||||
|
||||
//- Construct from an initializer list
|
||||
inline FixedList(std::initializer_list<T>);
|
||||
inline FixedList(std::initializer_list<T> lst);
|
||||
|
||||
//- Construct from UList
|
||||
explicit inline FixedList(const UList<T>&);
|
||||
explicit inline FixedList(const UList<T>& lst);
|
||||
|
||||
//- Construct from SLList
|
||||
explicit inline FixedList(const SLList<T>&);
|
||||
explicit inline FixedList(const SLList<T>& lst);
|
||||
|
||||
//- Copy constructor
|
||||
inline FixedList(const FixedList<T, Size>&);
|
||||
inline FixedList(const FixedList<T, Size>& lst);
|
||||
|
||||
//- Construct from Istream
|
||||
FixedList(Istream&);
|
||||
FixedList(Istream& is);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr<FixedList<T, Size>> clone() const;
|
||||
@ -205,39 +205,39 @@ public:
|
||||
|
||||
//- Dummy resize function
|
||||
// needed to make FixedList consistent with List
|
||||
inline void resize(const label);
|
||||
inline void resize(const label s);
|
||||
|
||||
//- Dummy setSize function
|
||||
// needed to make FixedList consistent with List
|
||||
inline void setSize(const label);
|
||||
inline void setSize(const label s);
|
||||
|
||||
//- Copy (not transfer) the argument contents
|
||||
// needed to make FixedList consistent with List
|
||||
void transfer(const FixedList<T, Size>&);
|
||||
void transfer(const FixedList<T, Size>& lst);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return element of FixedList
|
||||
inline T& operator[](const label);
|
||||
inline T& operator[](const label i);
|
||||
|
||||
//- Return element of constant FixedList
|
||||
inline const T& operator[](const label) const;
|
||||
inline const T& operator[](const label i) const;
|
||||
|
||||
//- Assignment to array operator. Takes linear time
|
||||
inline void operator=(const T v[Size]);
|
||||
inline void operator=(const T lst[Size]);
|
||||
|
||||
//- Assignment to UList operator. Takes linear time
|
||||
inline void operator=(const UList<T>&);
|
||||
inline void operator=(const UList<T>& lst);
|
||||
|
||||
//- Assignment to SLList operator. Takes linear time
|
||||
inline void operator=(const SLList<T>&);
|
||||
inline void operator=(const SLList<T>& lst);
|
||||
|
||||
//- Assignment to an initializer list. Takes linear time
|
||||
inline void operator=(std::initializer_list<T>);
|
||||
inline void operator=(std::initializer_list<T> lst);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T&);
|
||||
inline void operator=(const T& t);
|
||||
|
||||
|
||||
// STL type definitions
|
||||
@ -333,7 +333,7 @@ public:
|
||||
inline bool empty() const;
|
||||
|
||||
//- Swap two FixedLists of the same type in constant time
|
||||
void swap(FixedList<T, Size>&);
|
||||
void swap(FixedList<T, Size>& a);
|
||||
|
||||
|
||||
// STL member operators
|
||||
@ -341,22 +341,22 @@ public:
|
||||
//- Equality operation on FixedLists of the same type.
|
||||
// Returns true when the FixedLists are elementwise equal
|
||||
// (using FixedList::value_type::operator==). Takes linear time
|
||||
bool operator==(const FixedList<T, Size>&) const;
|
||||
bool operator==(const FixedList<T, Size>& a) const;
|
||||
|
||||
//- The opposite of the equality operation. Takes linear time
|
||||
bool operator!=(const FixedList<T, Size>&) const;
|
||||
bool operator!=(const FixedList<T, Size>& a) const;
|
||||
|
||||
//- Compare two FixedLists lexicographically. Takes linear time
|
||||
bool operator<(const FixedList<T, Size>&) const;
|
||||
bool operator<(const FixedList<T, Size>& a) const;
|
||||
|
||||
//- Compare two FixedLists lexicographically. Takes linear time
|
||||
bool operator>(const FixedList<T, Size>&) const;
|
||||
bool operator>(const FixedList<T, Size>& a) const;
|
||||
|
||||
//- Return true if !(a > b). Takes linear time
|
||||
bool operator<=(const FixedList<T, Size>&) const;
|
||||
bool operator<=(const FixedList<T, Size>& a) const;
|
||||
|
||||
//- Return true if !(a < b). Takes linear time
|
||||
bool operator>=(const FixedList<T, Size>&) const;
|
||||
bool operator>=(const FixedList<T, Size>& a) const;
|
||||
|
||||
|
||||
// Writing
|
||||
@ -365,17 +365,21 @@ public:
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
|
||||
|
||||
|
||||
// IOstream operators
|
||||
|
||||
//- Read List from Istream, discarding contents of existing List
|
||||
friend Istream& operator>> <T, Size>
|
||||
(Istream&, FixedList<T, Size>&);
|
||||
(
|
||||
Istream& is,
|
||||
FixedList<T, Size>& L
|
||||
);
|
||||
|
||||
//- Write FixedList to Ostream
|
||||
friend Ostream& operator<< <T, Size>
|
||||
(
|
||||
Ostream&,
|
||||
const FixedList<T, Size>&
|
||||
Ostream& os,
|
||||
const FixedList<T, Size>& L
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
}
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("FixedList");
|
||||
const char delimiter = is.readBeginList("FixedList");
|
||||
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
|
||||
@ -74,13 +74,13 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
if (is.format() == IOstream::ASCII || !contiguous<T>())
|
||||
{
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("List");
|
||||
const char delimiter = is.readBeginList("List");
|
||||
|
||||
if (s)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
is >> L[i];
|
||||
|
||||
@ -103,7 +103,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
L[i] = element;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ extern const labelList emptyLabelList;
|
||||
template<class Type>
|
||||
static const List<Type>& emptyList()
|
||||
{
|
||||
return *reinterpret_cast<const List<Type>* >(&emptyLabelList);
|
||||
return *reinterpret_cast<const List<Type>*>(&emptyLabelList);
|
||||
}
|
||||
|
||||
//- Renumber the values (not the indices) of a list.
|
||||
@ -263,7 +263,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Helper class for list to append unique elelements of y onto the end of x
|
||||
//- Helper class for list to append unique elements of y onto the end of x
|
||||
template<class T>
|
||||
class ListUniqueEqOp
|
||||
{
|
||||
|
||||
@ -48,12 +48,13 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
// Read size of list
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
setSize(s);
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("PtrList");
|
||||
const char delimiter = is.readBeginList("PtrList");
|
||||
|
||||
if (s)
|
||||
{
|
||||
@ -81,7 +82,7 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (label i=1; i<s; i++)
|
||||
for (label i=1; i<s; ++i)
|
||||
{
|
||||
set(i, tPtr->clone());
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
||||
template<class T>
|
||||
inline Foam::SubList<T>::operator const Foam::List<T>&() const
|
||||
{
|
||||
return *reinterpret_cast<const List<T>* >(this);
|
||||
return *reinterpret_cast<const List<T>*>(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -70,7 +70,11 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given the complete list and the addressing array
|
||||
inline UIndirectList(const UList<T>&, const labelUList&);
|
||||
inline UIndirectList
|
||||
(
|
||||
const UList<T>& completeList,
|
||||
const labelUList& addr
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -108,19 +112,19 @@ public:
|
||||
inline List<T> operator()() const;
|
||||
|
||||
//- Return non-const access to an element
|
||||
inline T& operator[](const label);
|
||||
inline T& operator[](const label i);
|
||||
|
||||
//- Return const access to an element
|
||||
inline const T& operator[](const label) const;
|
||||
inline const T& operator[](const label i) const;
|
||||
|
||||
//- Assignment to UList of addressed elements
|
||||
inline void operator=(const UList<T>&);
|
||||
inline void operator=(const UList<T>& ae);
|
||||
|
||||
//- Assignment to UIndirectList of addressed elements
|
||||
inline void operator=(const UIndirectList<T>&);
|
||||
inline void operator=(const UIndirectList<T>& ae);
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
inline void operator=(const T&);
|
||||
inline void operator=(const T& t);
|
||||
|
||||
|
||||
// STL type definitions
|
||||
@ -146,12 +150,11 @@ public:
|
||||
|
||||
// Ostream operator
|
||||
|
||||
//- Write UIndirectList to Ostream
|
||||
// Binary output is currently still a bit of a problem
|
||||
//- Write List to Ostream, as per write() method with shortListLen=10
|
||||
friend Ostream& operator<< <T>
|
||||
(
|
||||
Ostream&,
|
||||
const UIndirectList<T>&
|
||||
Ostream& os,
|
||||
const UIndirectList<T>& L
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -222,27 +222,27 @@ public:
|
||||
|
||||
|
||||
//- Copy the pointer held by the given UList
|
||||
inline void shallowCopy(const UList<T>&);
|
||||
inline void shallowCopy(const UList<T>& a);
|
||||
|
||||
//- Copy elements of the given UList
|
||||
void deepCopy(const UList<T>&);
|
||||
void deepCopy(const UList<T>& a);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return element of UList
|
||||
inline T& operator[](const label);
|
||||
inline T& operator[](const label i);
|
||||
|
||||
//- Return element of constant UList
|
||||
// Note that the bool specialization adds lazy evaluation so reading
|
||||
// an out-of-range element returns false without any ill-effects
|
||||
inline const T& operator[](const label) const;
|
||||
inline const T& operator[](const label i) const;
|
||||
|
||||
//- Allow cast to a const List<T>&
|
||||
inline operator const Foam::List<T>&() const;
|
||||
|
||||
//- Assignment of all entries to the given value
|
||||
void operator=(const T&);
|
||||
void operator=(const T& t);
|
||||
|
||||
//- Assignment of all entries to zero
|
||||
void operator=(const zero);
|
||||
@ -341,7 +341,7 @@ public:
|
||||
inline bool empty() const;
|
||||
|
||||
//- Swap two ULists of the same type in constant time
|
||||
void swap(UList<T>&);
|
||||
void swap(UList<T>& a);
|
||||
|
||||
|
||||
// STL member operators
|
||||
@ -349,22 +349,22 @@ public:
|
||||
//- Equality operation on ULists of the same type.
|
||||
// Returns true when the ULists are element-wise equal
|
||||
// (using UList::value_type::operator==). Takes linear time
|
||||
bool operator==(const UList<T>&) const;
|
||||
bool operator==(const UList<T>& a) const;
|
||||
|
||||
//- The opposite of the equality operation. Takes linear time
|
||||
bool operator!=(const UList<T>&) const;
|
||||
bool operator!=(const UList<T>& a) const;
|
||||
|
||||
//- Compare two ULists lexicographically. Takes linear time
|
||||
bool operator<(const UList<T>&) const;
|
||||
bool operator<(const UList<T>& a) const;
|
||||
|
||||
//- Compare two ULists lexicographically. Takes linear time
|
||||
bool operator>(const UList<T>&) const;
|
||||
bool operator>(const UList<T>& a) const;
|
||||
|
||||
//- Return true if !(a > b). Takes linear time
|
||||
bool operator<=(const UList<T>&) const;
|
||||
bool operator<=(const UList<T>& a) const;
|
||||
|
||||
//- Return true if !(a < b). Takes linear time
|
||||
bool operator>=(const UList<T>&) const;
|
||||
bool operator>=(const UList<T>& a) const;
|
||||
|
||||
|
||||
// Writing
|
||||
@ -373,46 +373,47 @@ public:
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
|
||||
|
||||
// Ostream operator
|
||||
|
||||
// Write UList to Ostream
|
||||
// IOstream operators
|
||||
|
||||
//- Write List to Ostream, as per write() method with shortListLen=10
|
||||
friend Ostream& operator<< <T>
|
||||
(
|
||||
Ostream&,
|
||||
const UList<T>&
|
||||
Ostream& os,
|
||||
const UList<T>& L
|
||||
);
|
||||
|
||||
//- Read UList contents from Istream. Requires size to have been set
|
||||
// before
|
||||
//- Read List contents from Istream.
|
||||
// Requires size to have been set before
|
||||
friend Istream& operator>> <T>
|
||||
(
|
||||
Istream&,
|
||||
UList<T>&
|
||||
Istream& os,
|
||||
UList<T>& L
|
||||
);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void sort(UList<T>&);
|
||||
void sort(UList<T>& a);
|
||||
|
||||
template<class T, class Cmp>
|
||||
void sort(UList<T>&, const Cmp&);
|
||||
void sort(UList<T>& a, const Cmp& cmp);
|
||||
|
||||
template<class T>
|
||||
void stableSort(UList<T>&);
|
||||
void stableSort(UList<T>& a);
|
||||
|
||||
template<class T, class Cmp>
|
||||
void stableSort(UList<T>&, const Cmp&);
|
||||
void stableSort(UList<T>& a, const Cmp& cmp);
|
||||
|
||||
template<class T>
|
||||
void shuffle(UList<T>&);
|
||||
void shuffle(UList<T>& a);
|
||||
|
||||
// Reverse the first n elements of the list
|
||||
template<class T>
|
||||
inline void reverse(UList<T>&, const label n);
|
||||
inline void reverse(UList<T>& ul, const label n);
|
||||
|
||||
// Reverse all the elements of the list
|
||||
template<class T>
|
||||
inline void reverse(UList<T>&);
|
||||
inline void reverse(UList<T>& ul);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -201,7 +201,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
if (is.format() == IOstream::ASCII || !contiguous<T>())
|
||||
{
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("List");
|
||||
const char delimiter = is.readBeginList("List");
|
||||
|
||||
if (s)
|
||||
{
|
||||
|
||||
@ -139,7 +139,7 @@ inline void Foam::SubField<Type>::operator=
|
||||
template<class Type>
|
||||
inline Foam::SubField<Type>::operator const Foam::Field<Type>&() const
|
||||
{
|
||||
return *reinterpret_cast<const Field<Type>* >(this);
|
||||
return *reinterpret_cast<const Field<Type>*>(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,21 +37,19 @@ void Foam::blockMeshTools::read
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
L.setSize(s);
|
||||
|
||||
// Read list contents depending on data format
|
||||
|
||||
// Read beginning of contents
|
||||
char delimiter = is.readBeginList("List");
|
||||
const char delimiter = is.readBeginList("List");
|
||||
|
||||
if (s)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
read(is, L[i], dict);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user