mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: expose List uniform() method as public
This commit is contained in:
@ -90,9 +90,6 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
//- Write the FixedList with its compound type
|
||||
void writeEntry(Ostream& os) const;
|
||||
|
||||
@ -242,6 +239,9 @@ public:
|
||||
//- Check index is within valid range [0,N)
|
||||
inline void checkIndex(const label i) const;
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
|
||||
// Search
|
||||
|
||||
|
||||
@ -37,25 +37,6 @@ inline const Foam::FixedList<T, N>& Foam::FixedList<T, N>::null()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline bool Foam::FixedList<T, N>::uniform() const
|
||||
{
|
||||
if (empty()) return false; // <- Compile-time disabled anyhow
|
||||
|
||||
for (unsigned i=1; i<N; ++i)
|
||||
{
|
||||
if (v_[0] != v_[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned N>
|
||||
@ -299,6 +280,23 @@ inline void Foam::FixedList<T, N>::checkIndex(const label i) const
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline bool Foam::FixedList<T, N>::uniform() const
|
||||
{
|
||||
if (empty()) return false; // <- Compile-time disabled anyhow
|
||||
|
||||
for (unsigned i=1; i<N; ++i)
|
||||
{
|
||||
if (v_[0] != v_[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline bool Foam::FixedList<T, N>::found
|
||||
(
|
||||
|
||||
@ -67,14 +67,6 @@ class UIndirectList
|
||||
UList<T>& values_;
|
||||
const labelUList& addressing_;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// STL type definitions
|
||||
@ -123,6 +115,9 @@ public:
|
||||
//- Return true if the list is empty (ie, size() is zero).
|
||||
inline bool empty() const;
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
//- Return the first element of the list.
|
||||
inline T& first();
|
||||
|
||||
|
||||
@ -23,32 +23,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UIndirectList<T>::uniform() const
|
||||
{
|
||||
const label len = this->size();
|
||||
|
||||
if (!len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const T& val = (*this)[0];
|
||||
|
||||
for (label i=1; i<len; ++i)
|
||||
{
|
||||
if (val != (*this)[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -79,6 +53,32 @@ inline bool Foam::UIndirectList<T>::empty() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UIndirectList<T>::uniform() const
|
||||
{
|
||||
const label len = this->size();
|
||||
|
||||
if (!len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const T& val = (*this)[0];
|
||||
|
||||
for (label i=1; i<len; ++i)
|
||||
{
|
||||
if (val != (*this)[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UIndirectList<T>::first()
|
||||
{
|
||||
|
||||
@ -112,9 +112,6 @@ protected:
|
||||
// Use with care
|
||||
inline void size(const label n);
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
//- Write the UList with its compound type
|
||||
void writeEntry(Ostream& os) const;
|
||||
|
||||
@ -291,6 +288,9 @@ public:
|
||||
//- Check index is within valid range [0,size)
|
||||
inline void checkIndex(const label i) const;
|
||||
|
||||
//- True if all entries have identical values, and list is non-empty
|
||||
inline bool uniform() const;
|
||||
|
||||
|
||||
// Search
|
||||
|
||||
|
||||
@ -27,33 +27,6 @@ License
|
||||
#include "pTraits.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UList<T>::uniform() const
|
||||
{
|
||||
const label len = size();
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const T& val = first();
|
||||
|
||||
for (label i=1; i<len; ++i)
|
||||
{
|
||||
if (val != (*this)[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -166,6 +139,30 @@ inline void Foam::UList<T>::checkIndex(const label i) const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UList<T>::uniform() const
|
||||
{
|
||||
const label len = size();
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const T& val = first();
|
||||
|
||||
for (label i=1; i<len; ++i)
|
||||
{
|
||||
if (val != (*this)[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UList<T>::first()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user