STYLE: consistent indentation and template parameters for FixedList

This commit is contained in:
Mark Olesen
2019-01-08 21:50:12 +01:00
parent 14a404170b
commit 907dd6d49f
27 changed files with 480 additions and 489 deletions

View File

@ -42,11 +42,11 @@ See also
using namespace Foam;
template<class T, unsigned Size>
Ostream& printInfo(const FixedList<List<T>, Size>& list)
template<class T, unsigned N>
Ostream& printInfo(const FixedList<List<T>, N>& list)
{
Info<< list << " addresses:";
for (unsigned i = 0; i < Size; ++i)
for (unsigned i = 0; i < N; ++i)
{
Info<< " " << long(list[i].cdata());
}
@ -55,11 +55,11 @@ Ostream& printInfo(const FixedList<List<T>, Size>& list)
}
template<class T, unsigned Size>
template<class T, unsigned N>
Ostream& printInfo
(
const FixedList<List<T>, Size>& list1,
const FixedList<List<T>, Size>& list2
const FixedList<List<T>, N>& list1,
const FixedList<List<T>, N>& list2
)
{
Info<< "llist1:"; printInfo(list1);
@ -139,15 +139,15 @@ int main(int argc, char *argv[])
FixedList<label, 4> list1{2, 3, 4, 5};
Info<< "list1:" << list1
<< " hash:" << FixedList<label,4>::Hash<>()(list1) << nl
<< " hash:" << Hash<FixedList<label,4>>()(list1) << nl;
<< " hash:" << FixedList<label, 4>::Hash<>()(list1) << nl
<< " hash:" << Hash<FixedList<label, 4>>()(list1) << nl;
label a[4] = {0, 1, 2, 3};
FixedList<label, 4> list2(a);
Info<< "list2:" << list2
<< " hash:" << FixedList<label,4>::Hash<>()(list2) << nl
<< " hash:" << Hash<FixedList<label,4>>()(list2) << nl;
<< " hash:" << FixedList<label, 4>::Hash<>()(list2) << nl
<< " hash:" << Hash<FixedList<label, 4>>()(list2) << nl;
// Using FixedList for content too

View File

@ -57,8 +57,8 @@ inline Foam::label Foam::HashSet<Key, Hash>::assignMany
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Key, class Hash>
template<unsigned Size>
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& list)
template<unsigned N>
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, N>& list)
:
parent_type(2*list.size())
{
@ -154,10 +154,10 @@ inline Foam::label Foam::HashSet<Key, Hash>::insert
template<class Key, class Hash>
template<unsigned Size>
template<unsigned N>
inline Foam::label Foam::HashSet<Key, Hash>::insert
(
const FixedList<Key, Size>& list
const FixedList<Key, N>& list
)
{
return insert(list.begin(), list.end());
@ -207,10 +207,10 @@ inline Foam::label Foam::HashSet<Key, Hash>::unset
template<class Key, class Hash>
template<unsigned Size>
template<unsigned N>
inline Foam::label Foam::HashSet<Key, Hash>::unset
(
const FixedList<Key, Size>& list
const FixedList<Key, N>& list
)
{
return unset(list.begin(), list.end());
@ -254,8 +254,8 @@ inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
template<class Key, class Hash>
template<unsigned Size>
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& rhs)
template<unsigned N>
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, N>& rhs)
{
assignMany(rhs.size(), rhs.begin(), rhs.end());
}

View File

@ -134,8 +134,8 @@ public:
{}
//- Construct from FixedList of Key
template<unsigned Size>
explicit HashSet(const FixedList<Key, Size>& list);
template<unsigned N>
explicit HashSet(const FixedList<Key, N>& list);
//- Construct from UList of Key
explicit HashSet(const UList<Key>& list);
@ -203,8 +203,8 @@ public:
//- Insert keys from the list of Key
// \return The number of new elements inserted
template<unsigned Size>
inline label insert(const FixedList<Key, Size>& list);
template<unsigned N>
inline label insert(const FixedList<Key, N>& list);
//- Insert keys from the list of Key
// \return The number of new elements inserted
@ -228,8 +228,8 @@ public:
}
//- Same as insert (no value to overwrite)
template<unsigned Size>
inline label set(const FixedList<Key, Size>& list)
template<unsigned N>
inline label set(const FixedList<Key, N>& list)
{
return insert(list);
}
@ -265,8 +265,8 @@ public:
//- Unset the listed keys - same as erase
// \return The number of items removed
template<unsigned Size>
inline label unset(const FixedList<Key, Size>& list);
template<unsigned N>
inline label unset(const FixedList<Key, N>& list);
//- Unset the listed keys - same as erase
// \return The number of items removed
@ -338,8 +338,8 @@ public:
void operator=(const UList<Key>& rhs);
//- Assignment from a FixedList of keys
template<unsigned Size>
void operator=(const FixedList<Key, Size>& rhs);
template<unsigned N>
void operator=(const FixedList<Key, N>& rhs);
//- Assignment from an initializer list of keys
void operator=(std::initializer_list<Key> rhs);

View File

@ -443,10 +443,10 @@ inline Foam::label Foam::HashTable<T, Key, Hash>::erase
template<class T, class Key, class Hash>
template<unsigned Size>
template<unsigned N>
inline Foam::label Foam::HashTable<T, Key, Hash>::erase
(
const FixedList<Key, Size>& keys
const FixedList<Key, N>& keys
)
{
return erase(keys.cbegin(), keys.cend());

View File

@ -99,7 +99,7 @@ namespace Foam
template<class T> class List;
template<class T> class UList;
template<class T, unsigned Size> class FixedList;
template<class T, unsigned N> class FixedList;
template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash>
@ -406,8 +406,8 @@ public:
//- Remove table entries given by the listed keys
// \return The number of items removed
template<unsigned Size>
inline label erase(const FixedList<Key, Size>& keys);
template<unsigned N>
inline label erase(const FixedList<Key, N>& keys);
//- Remove table entries given by the listed keys
// \return The number of items removed

View File

@ -138,8 +138,8 @@ public:
inline explicit DynamicList(const UList<T>& lst);
//- Construct from a FixedList
template<unsigned FixedSize>
inline DynamicList(const FixedList<T, FixedSize>& lst);
template<unsigned N>
inline DynamicList(const FixedList<T, N>& lst);
//- Construct given begin/end iterators.
// Uses std::distance to determine the size.
@ -249,9 +249,9 @@ public:
inline DynamicList<T, SizeMin>& append(const UList<T>& lst);
//- Append a FixedList to the end of this list.
template<unsigned FixedSize>
template<unsigned N>
inline DynamicList<T, SizeMin>&
append(const FixedList<T, FixedSize>& lst);
append(const FixedList<T, N>& lst);
//- Append an initializer list at the end of this list.
inline DynamicList<T, SizeMin>&
@ -323,8 +323,8 @@ public:
inline void operator=(const UList<T>& lst);
//- Assignment to FixedList
template<unsigned FixedSize>
inline void operator=(const FixedList<T, FixedSize>& lst);
template<unsigned N>
inline void operator=(const FixedList<T, N>& lst);
//- Assignment to DynamicList
inline void operator=(const DynamicList<T, SizeMin>& lst);

View File

@ -130,10 +130,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
template<class T, int SizeMin>
template<unsigned FixedSize>
template<unsigned N>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const FixedList<T, FixedSize>& lst
const FixedList<T, N>& lst
)
:
capacity_(0)
@ -515,11 +515,11 @@ Foam::DynamicList<T, SizeMin>::append
template<class T, int SizeMin>
template<unsigned FixedSize>
template<unsigned N>
inline Foam::DynamicList<T, SizeMin>&
Foam::DynamicList<T, SizeMin>::append
(
const FixedList<T, FixedSize>& lst
const FixedList<T, N>& lst
)
{
label idx = List<T>::size();
@ -770,10 +770,10 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
template<class T, int SizeMin>
template<unsigned FixedSize>
template<unsigned N>
inline void Foam::DynamicList<T, SizeMin>::operator=
(
const FixedList<T, FixedSize>& lst
const FixedList<T, N>& lst
)
{
const label n = lst.size();

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,8 +28,8 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, unsigned Size>
Foam::label Foam::FixedList<T, Size>::find
template<class T, unsigned N>
Foam::label Foam::FixedList<T, N>::find
(
const T& val,
const label start
@ -39,7 +39,7 @@ Foam::label Foam::FixedList<T, Size>::find
{
List_CONST_ACCESS(T, *this, list);
for (label i = start; i < label(Size); ++i)
for (label i = start; i < label(N); ++i)
{
if (list[i] == val)
{
@ -52,8 +52,8 @@ Foam::label Foam::FixedList<T, Size>::find
}
template<class T, unsigned Size>
void Foam::FixedList<T, Size>::moveFirst(const label i)
template<class T, unsigned N>
void Foam::FixedList<T, N>::moveFirst(const label i)
{
checkIndex(i);
@ -64,20 +64,20 @@ void Foam::FixedList<T, Size>::moveFirst(const label i)
}
template<class T, unsigned Size>
void Foam::FixedList<T, Size>::moveLast(const label i)
template<class T, unsigned N>
void Foam::FixedList<T, N>::moveLast(const label i)
{
checkIndex(i);
for (label upper = label(Size - 1); upper > i; --upper)
for (label upper = label(N-1); upper > i; --upper)
{
Foam::Swap(v_[i], v_[upper]);
}
}
template<class T, unsigned Size>
void Foam::FixedList<T, Size>::swapFirst(const label i)
template<class T, unsigned N>
void Foam::FixedList<T, N>::swapFirst(const label i)
{
checkIndex(i);
@ -88,12 +88,12 @@ void Foam::FixedList<T, Size>::swapFirst(const label i)
}
template<class T, unsigned Size>
void Foam::FixedList<T, Size>::swapLast(const label i)
template<class T, unsigned N>
void Foam::FixedList<T, N>::swapLast(const label i)
{
checkIndex(i);
const label upper = label(Size - 1);
const label upper = label(N-1);
if (i < upper)
{
@ -104,14 +104,14 @@ void Foam::FixedList<T, Size>::swapLast(const label i)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, unsigned Size>
bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& list) const
template<class T, unsigned N>
bool Foam::FixedList<T, N>::operator==(const FixedList<T, N>& list) const
{
List_CONST_ACCESS(T, *this, lhs);
List_CONST_ACCESS(T, (list), rhs);
// List sizes are identical by definition (template parameter)
for (unsigned i = 0; i < Size; ++i)
for (unsigned i = 0; i < N; ++i)
{
if (!(lhs[i] == rhs[i]))
{
@ -124,14 +124,14 @@ bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& list) const
}
template<class T, unsigned Size>
bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& list) const
template<class T, unsigned N>
bool Foam::FixedList<T, N>::operator<(const FixedList<T, N>& list) const
{
List_CONST_ACCESS(T, *this, lhs);
List_CONST_ACCESS(T, (list), rhs);
// List sizes are identical by definition (template parameter)
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
if (lhs[i] < rhs[i])
{
@ -148,29 +148,29 @@ bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& list) const
}
template<class T, unsigned Size>
bool Foam::FixedList<T, Size>::operator!=(const FixedList<T, Size>& list) const
template<class T, unsigned N>
bool Foam::FixedList<T, N>::operator!=(const FixedList<T, N>& list) const
{
return !operator==(list);
}
template<class T, unsigned Size>
bool Foam::FixedList<T, Size>::operator>(const FixedList<T, Size>& list) const
template<class T, unsigned N>
bool Foam::FixedList<T, N>::operator>(const FixedList<T, N>& list) const
{
return list.operator<(*this);
}
template<class T, unsigned Size>
bool Foam::FixedList<T, Size>::operator<=(const FixedList<T, Size>& list) const
template<class T, unsigned N>
bool Foam::FixedList<T, N>::operator<=(const FixedList<T, N>& list) const
{
return !list.operator<(*this);
}
template<class T, unsigned Size>
bool Foam::FixedList<T, Size>::operator>=(const FixedList<T, Size>& list) const
template<class T, unsigned N>
bool Foam::FixedList<T, N>::operator>=(const FixedList<T, N>& list) const
{
return !operator<(list);
}

View File

@ -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) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ Class
Foam::FixedList
Description
A 1D vector of objects of type \<T\> with a fixed size \<Size\>.
A 1D vector of objects of type \<T\> with a fixed length \<N\>.
SourceFiles
FixedList.C
@ -57,36 +57,32 @@ SourceFiles
namespace Foam
{
// Forward declarations
template<class T, unsigned Size> class FixedList;
template<class T, unsigned Size>
Istream& operator>>(Istream&, FixedList<T, Size>&);
template<class T, unsigned Size>
Ostream& operator<<(Ostream&, const FixedList<T, Size>&);
// Forward Declarations
template<class T, unsigned N> class FixedList;
template<class T> class UList;
template<class T, unsigned N>
Istream& operator>>(Istream& is, FixedList<T, N>& list);
/*---------------------------------------------------------------------------*\
Class FixedList Declaration
\*---------------------------------------------------------------------------*/
template<class T, unsigned Size>
template<class T, unsigned N>
class FixedList
{
static_assert
(
Size && Size <= std::numeric_limits<int>::max(),
"Size must be positive (non-zero) and also fit as a signed value"
N && N <= std::numeric_limits<int>::max(),
"Size must be positive (non-zero) and fit as a signed int value"
);
// Private data
// Private Data
//- Vector of values of type T of size Size.
T v_[Size];
//- Vector of values of type T of length N.
T v_[N];
protected:
@ -100,6 +96,7 @@ protected:
//- Write the FixedList with its compound type
void writeEntry(Ostream& os) const;
public:
// STL type definitions
@ -141,7 +138,7 @@ public:
// Static Member Functions
//- Return a null FixedList
inline static const FixedList<T, Size>& null();
inline static const FixedList<T, N>& null();
// Constructors
@ -156,14 +153,14 @@ public:
inline explicit FixedList(const zero);
//- Copy construct from C-array
inline explicit FixedList(const T list[Size]);
inline explicit FixedList(const T list[N]);
//- Copy constructor
inline FixedList(const FixedList<T, Size>& list);
inline FixedList(const FixedList<T, N>& list);
//- Move construct by using move assignment for the individual
//- list elements
inline FixedList(FixedList<T, Size>&& list);
inline FixedList(FixedList<T, N>&& list);
//- Construct given begin/end iterators
// Uses std::distance when verifying the size.
@ -183,67 +180,67 @@ public:
explicit FixedList(Istream& is);
//- Clone
inline autoPtr<FixedList<T, Size>> clone() const;
inline autoPtr<FixedList<T, N>> clone() const;
// Member Functions
// Access
// Access
//- Return the forward circular index, i.e. next index
//- which returns to the first at the end of the list
inline label fcIndex(const label i) const;
//- Return a const pointer to the first data element.
// Similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code
inline const T* cdata() const;
//- Return forward circular value (ie, next value in the list)
inline const T& fcValue(const label i) const;
//- Return a pointer to the first data element.
// Similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code
inline T* data();
//- Return forward circular value (ie, next value in the list)
inline T& fcValue(const label i);
//- Return the first element of the list
inline T& first();
//- Return the reverse circular index, i.e. previous index
//- which returns to the last at the beginning of the list
inline label rcIndex(const label i) const;
//- Return first element of the list
inline const T& first() const;
//- Return reverse circular value (ie, previous value in the list)
inline const T& rcValue(const label i) const;
//- Return the last element of the list
inline T& last();
//- Return reverse circular value (ie, previous value in the list)
inline T& rcValue(const label i);
//- Return the last element of the list
inline const T& last() const;
//- Return a const pointer to the first data element.
// Similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code
inline const T* cdata() const;
//- Return the forward circular index, i.e. next index
//- which returns to the first at the end of the list
inline label fcIndex(const label i) const;
//- Return a pointer to the first data element.
// Similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code
inline T* data();
//- Return forward circular value (ie, next value in the list)
inline const T& fcValue(const label i) const;
//- Return the first element of the list
inline T& first();
//- Return forward circular value (ie, next value in the list)
inline T& fcValue(const label i);
//- Return first element of the list
inline const T& first() const;
//- Return the reverse circular index, i.e. previous index
//- which returns to the last at the beginning of the list
inline label rcIndex(const label i) const;
//- Return the last element of the list
inline T& last();
//- Return reverse circular value (ie, previous value in the list)
inline const T& rcValue(const label i) const;
//- Return the last element of the list
inline const T& last() const;
//- Return reverse circular value (ie, previous value in the list)
inline T& rcValue(const label i);
// Check
// Check
//- Check start is within valid range [0,size)
inline void checkStart(const label start) const;
//- Check start is within valid range [0,size)
inline void checkStart(const label start) const;
//- Check size is identical to Size template parameter
inline void checkSize(const label size) const;
//- Check size is identical to template parameter N
inline void checkSize(const label size) const;
//- Check index is within valid range [0,size)
inline void checkIndex(const label i) const;
//- Check index is within valid range [0,N)
inline void checkIndex(const label i) const;
// Search
@ -259,12 +256,10 @@ public:
// Edit
//- Dummy resize function
// needed to make FixedList consistent with List
//- Dummy resize function, to make FixedList consistent with List
inline void resize(const label n);
//- Dummy setSize function
// needed to make FixedList consistent with List
//- Dummy setSize function, to make FixedList consistent with List
inline void setSize(const label n);
//- Move element to the first position.
@ -281,7 +276,7 @@ public:
//- Transfer by swapping using a move assignment for the content
//- of the individual list elements
inline void transfer(FixedList<T, Size>& list);
inline void transfer(FixedList<T, N>& list);
// Member operators
@ -293,7 +288,7 @@ public:
inline const T& operator[](const label i) const;
//- Assignment to array operator. Takes linear time
inline void operator=(const T list[Size]);
inline void operator=(const T list[N]);
//- Assignment to UList operator. Takes linear time
inline void operator=(const UList<T>& list);
@ -308,10 +303,10 @@ public:
inline void operator=(const T& val);
//- Copy assignment
inline void operator=(const FixedList<T, Size>& list);
inline void operator=(const FixedList<T, N>& list);
//- Move assignment
inline void operator=(FixedList<T, Size>&& list);
inline void operator=(FixedList<T, N>&& list);
// Random access iterator (non-const)
@ -374,7 +369,7 @@ public:
inline bool empty() const;
//- Swap lists by swapping the content of the individual list elements
inline void swap(FixedList<T, Size>& list);
inline void swap(FixedList<T, N>& list);
// STL member operators
@ -382,49 +377,42 @@ public:
//- Equality operation on FixedLists of the same type.
// Returns true when the FixedLists are element-wise equal
// (using FixedList::value_type::operator==). Takes linear time
bool operator==(const FixedList<T, Size>& list) const;
bool operator==(const FixedList<T, N>& list) const;
//- The opposite of the equality operation. Takes linear time
bool operator!=(const FixedList<T, Size>& list) const;
bool operator!=(const FixedList<T, N>& list) const;
//- Compare two FixedLists lexicographically. Takes linear time
bool operator<(const FixedList<T, Size>& list) const;
bool operator<(const FixedList<T, N>& list) const;
//- Compare two FixedLists lexicographically. Takes linear time
bool operator>(const FixedList<T, Size>& list) const;
bool operator>(const FixedList<T, N>& list) const;
//- Return true if !(a > b). Takes linear time
bool operator<=(const FixedList<T, Size>& list) const;
bool operator<=(const FixedList<T, N>& list) const;
//- Return true if !(a < b). Takes linear time
bool operator>=(const FixedList<T, Size>& list) const;
bool operator>=(const FixedList<T, N>& list) const;
// Writing
//- Write the List as a dictionary entry with keyword
//- Write the list as a dictionary entry with keyword
void writeEntry(const word& keyword, Ostream& os) const;
//- Write the List, with line-breaks in ASCII if the list length
//- exceeds shortListLen.
//- Write the list, with line-breaks in ASCII if the length
//- exceeds shortLen.
// Using '0' suppresses line-breaks entirely.
Ostream& writeList(Ostream& os, const label shortListLen=0) const;
Ostream& writeList(Ostream& os, const label shortLen=0) const;
// IOstream operators
// IOstream Operators
//- Read from Istream, discarding contents of existing List
friend Istream& operator>> <T, Size>
friend Istream& operator>> <T, N>
(
Istream& is,
FixedList<T, Size>& list
);
//- Write to Ostream, as per writeList() with shortListLen=10
friend Ostream& operator<< <T, Size>
(
Ostream& os,
const FixedList<T, Size>& list
FixedList<T, N>& list
);
@ -438,13 +426,13 @@ public:
{
inline unsigned operator()
(
const FixedList<T, Size>& obj,
const FixedList<T, N>& obj,
unsigned seed=0
) const
{
if (contiguous<T>())
{
return Hasher(obj.cdata(), Size*sizeof(T), seed);
return Hasher(obj.cdata(), N*sizeof(T), seed);
}
for (const T& val : obj)
@ -461,8 +449,8 @@ public:
//- Swap FixedList contents - see FixedList::swap().
// Internally this actually swaps the individual list elements
template<class T, unsigned Size>
inline void Swap(FixedList<T,Size>& lhs, FixedList<T,Size>& rhs);
template<class T, unsigned N>
inline void Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs);
//- Hashing for FixedList data, which uses Hasher for contiguous data and
@ -490,10 +478,21 @@ struct Hash<FixedList<T, N>>
};
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Write to Ostream, as per FixedList::writeList() with shortLen=10
template<class T, unsigned N>
Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
{
return list.writeList(os, 10);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FixedListI.H"

View File

@ -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) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,16 +28,25 @@ License
#include <type_traits>
#include <utility>
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T, unsigned N>
inline const Foam::FixedList<T, N>& Foam::FixedList<T, N>::null()
{
return NullObjectRef<FixedList<T, N>>();
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class T, unsigned Size>
inline bool Foam::FixedList<T, Size>::uniform() const
template<class T, unsigned N>
inline bool Foam::FixedList<T, N>::uniform() const
{
if (Size > 1)
if (N > 1)
{
const T& val = first();
for (unsigned i=1; i<Size; ++i)
for (unsigned i=1; i<N; ++i)
{
if (val != (*this)[i])
{
@ -54,59 +63,59 @@ inline bool Foam::FixedList<T, Size>::uniform() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(const T& val)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const T& val)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = val;
}
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(const zero)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const zero)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = Zero;
}
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(const T list[Size])
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const T list[N])
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = list[i];
}
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& list)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const FixedList<T, N>& list)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = list.v_[i];
}
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(FixedList<T, Size>&& list)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(FixedList<T, N>&& list)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = std::move(list.v_[i]);
}
}
template<class T, unsigned Size>
template<class T, unsigned N>
template<class InputIterator>
inline Foam::FixedList<T, Size>::FixedList
inline Foam::FixedList<T, N>::FixedList
(
InputIterator begIter,
InputIterator endIter
@ -114,22 +123,21 @@ inline Foam::FixedList<T, Size>::FixedList
{
checkSize(std::distance(begIter, endIter));
InputIterator iter = begIter;
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = *iter;
++iter;
v_[i] = *begIter;
++begIter;
}
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(std::initializer_list<T> list)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(std::initializer_list<T> list)
{
checkSize(list.size());
auto iter = list.begin();
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = *iter;
++iter;
@ -137,25 +145,25 @@ inline Foam::FixedList<T, Size>::FixedList(std::initializer_list<T> list)
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(const UList<T>& list)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const UList<T>& list)
{
checkSize(list.size());
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = list[i];
}
}
template<class T, unsigned Size>
inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& list)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const SLList<T>& list)
{
checkSize(list.size());
auto iter = list.begin();
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = *iter;
++iter;
@ -163,104 +171,141 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& list)
}
template<class T, unsigned Size>
inline Foam::autoPtr<Foam::FixedList<T, Size>>
Foam::FixedList<T, Size>::clone() const
template<class T, unsigned N>
inline Foam::autoPtr<Foam::FixedList<T, N>>
Foam::FixedList<T, N>::clone() const
{
return autoPtr<FixedList<T, Size>>::New(*this);
return autoPtr<FixedList<T, N>>::New(*this);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, unsigned Size>
inline const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
template<class T, unsigned N>
inline const T*
Foam::FixedList<T, N>::cdata() const
{
return NullObjectRef<FixedList<T, Size>>();
return v_;
}
template<class T, unsigned Size>
inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
template<class T, unsigned N>
inline T*
Foam::FixedList<T, N>::data()
{
return (i == Size-1 ? 0 : i+1);
return v_;
}
template<class T, unsigned Size>
inline const T& Foam::FixedList<T, Size>::fcValue(const label i) const
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::first()
{
return v_[0];
}
template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::first() const
{
return v_[0];
}
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::last()
{
return v_[N-1];
}
template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::last() const
{
return v_[N-1];
}
template<class T, unsigned N>
inline Foam::label Foam::FixedList<T, N>::fcIndex(const label i) const
{
return (i == N-1 ? 0 : i+1);
}
template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::fcValue(const label i) const
{
return this->operator[](this->fcIndex(i));
}
template<class T, unsigned Size>
inline T& Foam::FixedList<T, Size>::fcValue(const label i)
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::fcValue(const label i)
{
return this->operator[](this->fcIndex(i));
}
template<class T, unsigned Size>
inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
template<class T, unsigned N>
inline Foam::label Foam::FixedList<T, N>::rcIndex(const label i) const
{
return (i ? i-1 : Size-1);
return (i ? i-1 : N-1);
}
template<class T, unsigned Size>
inline const T& Foam::FixedList<T, Size>::rcValue(const label i) const
template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::rcValue(const label i) const
{
return this->operator[](this->rcIndex(i));
}
template<class T, unsigned Size>
inline T& Foam::FixedList<T, Size>::rcValue(const label i)
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::rcValue(const label i)
{
return this->operator[](this->rcIndex(i));
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::checkStart(const label start) const
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::checkStart(const label start) const
{
if (start < 0 || (start && unsigned(start) >= Size))
if (start < 0 || (start && unsigned(start) >= N))
{
// Note: always accept start=0, even for zero-sized lists
FatalErrorInFunction
<< "start " << start << " out of range [0," << Size << ")"
<< "start " << start << " out of range [0," << N << ")"
<< abort(FatalError);
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::checkSize(const label size) const
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::checkSize(const label size) const
{
if (unsigned(size) != Size)
if (unsigned(size) != N)
{
FatalErrorInFunction
<< "size " << size << " != " << Size
<< "size " << size << " != " << N
<< abort(FatalError);
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::checkIndex(const label i) const
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::checkIndex(const label i) const
{
if (i < 0 || unsigned(i) >= Size)
if (i < 0 || unsigned(i) >= N)
{
FatalErrorInFunction
<< "index " << i << " out of range [0," << Size << ")"
<< "index " << i << " out of range [0," << N << ")"
<< abort(FatalError);
}
}
template<class T, unsigned Size>
inline bool Foam::FixedList<T, Size>::found
template<class T, unsigned N>
inline bool Foam::FixedList<T, N>::found
(
const T& val,
const label start
@ -270,16 +315,16 @@ inline bool Foam::FixedList<T, Size>::found
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::resize(const label n)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::resize(const label n)
{
#ifdef FULLDEBUG
checkSize(n);
#endif
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::setSize(const label n)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::setSize(const label n)
{
#ifdef FULLDEBUG
checkSize(n);
@ -287,74 +332,30 @@ inline void Foam::FixedList<T, Size>::setSize(const label n)
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::swap(FixedList<T, N>& list)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
Foam::Swap(v_[i], list.v_[i]);
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::transfer(FixedList<T, Size>& list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::transfer(FixedList<T, N>& list)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = std::move(list[i]);
}
}
template<class T, unsigned Size>
inline const T*
Foam::FixedList<T, Size>::cdata() const
{
return v_;
}
template<class T, unsigned Size>
inline T*
Foam::FixedList<T, Size>::data()
{
return v_;
}
template<class T, unsigned Size>
inline T& Foam::FixedList<T, Size>::first()
{
return v_[0];
}
template<class T, unsigned Size>
inline const T& Foam::FixedList<T, Size>::first() const
{
return v_[0];
}
template<class T, unsigned Size>
inline T& Foam::FixedList<T, Size>::last()
{
return v_[Size-1];
}
template<class T, unsigned Size>
inline const T& Foam::FixedList<T, Size>::last() const
{
return v_[Size-1];
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, unsigned Size>
inline T& Foam::FixedList<T, Size>::operator[](const label i)
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::operator[](const label i)
{
#ifdef FULLDEBUG
checkIndex(i);
@ -363,8 +364,8 @@ inline T& Foam::FixedList<T, Size>::operator[](const label i)
}
template<class T, unsigned Size>
inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::operator[](const label i) const
{
#ifdef FULLDEBUG
checkIndex(i);
@ -373,76 +374,76 @@ inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(const T list[Size])
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(const T list[N])
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = list[i];
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(const UList<T>& list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(const UList<T>& list)
{
checkSize(list.size());
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = list[i];
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(const SLList<T>& list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(const SLList<T>& list)
{
checkSize(list.size());
auto iter = list.begin();
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = *iter;
++iter;
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(std::initializer_list<T> list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(std::initializer_list<T> list)
{
checkSize(list.size());
auto iter = list.begin();
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = *iter;
++iter;
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(const T& val)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(const T& val)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = val;
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(const FixedList<T, Size>& list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(const FixedList<T, N>& list)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = list.v_[i];
}
}
template<class T, unsigned Size>
inline void Foam::FixedList<T, Size>::operator=(FixedList<T, Size>&& list)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(FixedList<T, N>&& list)
{
// No significant speedup observed for copy assignment on simple types,
// use move assignment for generality with more complex types
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
v_[i] = std::move(list.v_[i]);
}
@ -451,118 +452,118 @@ inline void Foam::FixedList<T, Size>::operator=(FixedList<T, Size>&& list)
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::iterator
Foam::FixedList<T, Size>::begin()
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::iterator
Foam::FixedList<T, N>::begin()
{
return v_;
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_iterator
Foam::FixedList<T, Size>::begin() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::begin() const
{
return v_;
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_iterator
Foam::FixedList<T, Size>::cbegin() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::cbegin() const
{
return v_;
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::iterator
Foam::FixedList<T, Size>::end()
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::iterator
Foam::FixedList<T, N>::end()
{
return (v_ + Size);
return (v_ + N);
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_iterator
Foam::FixedList<T, Size>::end() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::end() const
{
return (v_ + Size);
return (v_ + N);
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_iterator
Foam::FixedList<T, Size>::cend() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::cend() const
{
return (v_ + Size);
return (v_ + N);
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::reverse_iterator
Foam::FixedList<T, Size>::rbegin()
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::reverse_iterator
Foam::FixedList<T, N>::rbegin()
{
return reverse_iterator(end());
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
Foam::FixedList<T, Size>::rbegin() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_reverse_iterator
Foam::FixedList<T, N>::rbegin() const
{
return const_reverse_iterator(end());
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
Foam::FixedList<T, Size>::crbegin() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_reverse_iterator
Foam::FixedList<T, N>::crbegin() const
{
return const_reverse_iterator(end());
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::reverse_iterator
Foam::FixedList<T, Size>::rend()
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::reverse_iterator
Foam::FixedList<T, N>::rend()
{
return reverse_iterator(begin());
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
Foam::FixedList<T, Size>::rend() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_reverse_iterator
Foam::FixedList<T, N>::rend() const
{
return const_reverse_iterator(begin());
}
template<class T, unsigned Size>
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
Foam::FixedList<T, Size>::crend() const
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_reverse_iterator
Foam::FixedList<T, N>::crend() const
{
return const_reverse_iterator(begin());
}
template<class T, unsigned Size>
inline Foam::label Foam::FixedList<T, Size>::size() const
template<class T, unsigned N>
inline Foam::label Foam::FixedList<T, N>::size() const
{
return Size;
return N;
}
template<class T, unsigned Size>
inline Foam::label Foam::FixedList<T, Size>::max_size() const
template<class T, unsigned N>
inline Foam::label Foam::FixedList<T, N>::max_size() const
{
return Size;
return N;
}
template<class T, unsigned Size>
inline bool Foam::FixedList<T, Size>::empty() const
template<class T, unsigned N>
inline bool Foam::FixedList<T, N>::empty() const
{
return false;
}
@ -570,8 +571,8 @@ inline bool Foam::FixedList<T, Size>::empty() const
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class T, unsigned Size>
inline void Foam::Swap(FixedList<T, Size>& lhs, FixedList<T, Size>& rhs)
template<class T, unsigned N>
inline void Foam::Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs)
{
lhs.swap(rhs);
}

View File

@ -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) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,23 +31,22 @@ License
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class T, unsigned Size>
void Foam::FixedList<T, Size>::writeEntry(Ostream& os) const
template<class T, unsigned N>
void Foam::FixedList<T, N>::writeEntry(Ostream& os) const
{
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
if (token::compound::isCompound(tag))
{
os << tag << ' ';
}
os << *this;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class T, unsigned Size>
void Foam::FixedList<T, Size>::writeEntry
template<class T, unsigned N>
void Foam::FixedList<T, N>::writeEntry
(
const word& keyword,
Ostream& os
@ -59,34 +58,34 @@ void Foam::FixedList<T, Size>::writeEntry
}
template<class T, unsigned Size>
Foam::Ostream& Foam::FixedList<T, Size>::writeList
template<class T, unsigned N>
Foam::Ostream& Foam::FixedList<T, N>::writeList
(
Ostream& os,
const label shortListLen
) const
{
const FixedList<T, Size>& list = *this;
const FixedList<T, N>& list = *this;
// Write list contents depending on data format
// Unlike UList, no compact output form (eg, "2{-1}") since a
// FixedList is generally small and we also want the same appearance
// for FixedList<T, 2> as Tuple2<T,T>
// Unlike UList, no compact output form since a FixedList is generally
// small and we desire a consistent appearance.
// Eg, FixedList<T,2> or Pair<T> as "(-1 -1)", not as "2{-1}"
if (os.format() == IOstream::ASCII || !contiguous<T>())
{
if
(
Size <= 1 || !shortListLen
|| (Size <= unsigned(shortListLen) && contiguous<T>())
N <= 1 || !shortListLen
|| (N <= unsigned(shortListLen) && contiguous<T>())
)
{
// Start delimiter
os << token::BEGIN_LIST;
// Contents
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
if (i) os << token::SPACE;
os << list[i];
@ -101,7 +100,7 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
os << nl << token::BEGIN_LIST << nl;
// Contents
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
os << list[i] << nl;
}
@ -115,7 +114,7 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
// Binary, contiguous
// write(...) includes surrounding start/end delimiters
os.write(reinterpret_cast<const char*>(list.cdata()), Size*sizeof(T));
os.write(reinterpret_cast<const char*>(list.cdata()), N*sizeof(T));
}
os.check(FUNCTION_NAME);
@ -125,15 +124,15 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, unsigned Size>
Foam::FixedList<T, Size>::FixedList(Istream& is)
template<class T, unsigned N>
Foam::FixedList<T, N>::FixedList(Istream& is)
{
operator>>(is, *this);
}
template<class T, unsigned Size>
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
template<class T, unsigned N>
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
{
is.fatalCheck(FUNCTION_NAME);
@ -143,7 +142,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
is.fatalCheck
(
"operator>>(Istream&, FixedList<T, Size>&) : "
"operator>>(Istream&, FixedList<T, N>&) : "
"reading first token"
);
@ -180,31 +179,31 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
if (delimiter == token::BEGIN_LIST)
{
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
is >> list[i];
is.fatalCheck
(
"operator>>(Istream&, FixedList<T, Size>&) : "
"operator>>(Istream&, FixedList<T, N>&) : "
"reading entry"
);
}
}
else
{
T element;
is >> element;
T val;
is >> val;
is.fatalCheck
(
"operator>>(Istream&, FixedList<T, Size>&) : "
"operator>>(Istream&, FixedList<T, N>&) : "
"reading the single entry"
);
for (unsigned i=0; i<Size; ++i)
for (unsigned i=0; i<N; ++i)
{
list[i] = element; // Copy the value
list[i] = val; // Copy the value
}
}
@ -215,11 +214,11 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
{
// Binary and contiguous
is.read(reinterpret_cast<char*>(list.data()), Size*sizeof(T));
is.read(reinterpret_cast<char*>(list.data()), N*sizeof(T));
is.fatalCheck
(
"operator>>(Istream&, FixedList<T, Size>&) : "
"operator>>(Istream&, FixedList<T, N>&) : "
"reading the binary block"
);
}
@ -228,11 +227,4 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
}
template<class T, unsigned Size>
Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& list)
{
return list.writeList(os, 10);
}
// ************************************************************************* //

View File

@ -32,7 +32,6 @@ License
#include "UIndirectList.H"
#include "BiIndirectList.H"
#include "contiguous.H"
#include <utility>
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -302,10 +301,10 @@ Foam::List<T>::List(InputIterator begIter, InputIterator endIter)
template<class T>
template<unsigned Size>
Foam::List<T>::List(const FixedList<T, Size>& list)
template<unsigned N>
Foam::List<T>::List(const FixedList<T, N>& list)
:
UList<T>(nullptr, Size)
UList<T>(nullptr, label(N))
{
doAlloc();
copyList(list);

View File

@ -58,7 +58,7 @@ class Istream;
class Ostream;
template<class T> class List;
template<class T, unsigned Size> class FixedList;
template<class T, unsigned N> class FixedList;
template<class T, int SizeMin> class DynamicList;
template<class T> class PtrList;
@ -160,9 +160,9 @@ public:
template<class InputIterator>
List(InputIterator begIter, InputIterator endIter);
//- Construct as copy of FixedList<T, Size>
template<unsigned Size>
explicit List(const FixedList<T, Size>& list);
//- Construct as copy of FixedList\<T, N\>
template<unsigned N>
explicit List(const FixedList<T, N>& list);
//- Construct as copy of PtrList<T>
explicit List(const PtrList<T>& list);

View File

@ -225,16 +225,16 @@ public:
//- Construct using data area from a FixedList
template<unsigned FixedSize>
template<unsigned N>
UIListStream
(
const FixedList<char,FixedSize>& buffer,
const FixedList<char, N>& buffer,
streamFormat format=ASCII,
versionNumber version=currentVersion,
const Foam::string& name="input"
)
:
UIListStream(buffer.cdata(), FixedSize, format, version, name)
UIListStream(buffer.cdata(), N, format, version, name)
{}
//- Construct using data area from a List and number of bytes

View File

@ -210,15 +210,15 @@ public:
{}
//- Construct using data area from a FixedList
template<unsigned FixedSize>
template<unsigned N>
UOListStream
(
FixedList<char,FixedSize>& buffer,
FixedList<char, N>& buffer,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
UOListStream(buffer.data(), FixedSize, format, version)
UOListStream(buffer.data(), N, format, version)
{}
//- Construct using data area from a List and its inherent storage size

View File

@ -114,11 +114,11 @@ public:
//- Construct bounding box as an indirect subset of the points.
// The indices could be from edge/triFace etc.
// Does parallel communication (doReduce = true)
template<unsigned Size>
template<unsigned N>
boundBox
(
const UList<point>& points,
const FixedList<label, Size>& indices,
const FixedList<label, N>& indices,
bool doReduce = true
);
@ -202,16 +202,16 @@ public:
inline void add(const tmp<pointField>& tpoints);
//- Extend to include the points.
template<unsigned Size>
void add(const FixedList<point, Size>& points);
template<unsigned N>
void add(const FixedList<point, N>& points);
//- Extend to include a (subsetted) point field.
// The indices could be from edge/triFace etc.
template<unsigned Size>
template<unsigned N>
void add
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
);
//- Extend to include a (subsetted) point field.
@ -266,11 +266,11 @@ public:
bool contains(const UList<point>& points) const;
//- Contains all of the (subsetted) points? (inside or on edge)
template<unsigned Size>
template<unsigned N>
bool contains
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
) const;
@ -290,11 +290,11 @@ public:
bool containsAny(const UList<point>& points) const;
//- Contains any of the (subsetted) points? (inside or on edge)
template<unsigned Size>
template<unsigned N>
bool containsAny
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
) const;
//- Contains any of the (subsetted) points? (inside or on edge)

View File

@ -28,11 +28,11 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<unsigned Size>
template<unsigned N>
Foam::boundBox::boundBox
(
const UList<point>& points,
const FixedList<label, Size>& indices,
const FixedList<label, N>& indices,
bool doReduce
)
:
@ -49,10 +49,10 @@ Foam::boundBox::boundBox
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<unsigned Size>
template<unsigned N>
void Foam::boundBox::add
(
const FixedList<point, Size>& points
const FixedList<point, N>& points
)
{
for (const point& p : points)
@ -62,11 +62,11 @@ void Foam::boundBox::add
}
template<unsigned Size>
template<unsigned N>
void Foam::boundBox::add
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
)
{
const label len = points.size();
@ -108,11 +108,11 @@ void Foam::boundBox::add
}
template<unsigned Size>
template<unsigned N>
inline bool Foam::boundBox::contains
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
) const
{
const label len = points.size();
@ -166,11 +166,11 @@ inline bool Foam::boundBox::contains
}
template<unsigned Size>
template<unsigned N>
inline bool Foam::boundBox::containsAny
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
) const
{
const label len = points.size();

View File

@ -185,8 +185,8 @@ public:
inline bool insert(const label index);
//- Insert values, using begin/end iterators.
template<class InputIter>
inline label insert(InputIter begIter, InputIter endIter);
template<class InputIterator>
inline label insert(InputIterator begIter, InputIterator endIter);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert.
@ -198,8 +198,8 @@ public:
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
template<unsigned Size>
inline label insert(const FixedList<label, Size>& list);
template<unsigned N>
inline label insert(const FixedList<label, N>& list);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert.
@ -214,8 +214,8 @@ public:
inline label erase(const label index);
//- Remove values, using begin/end iterators.
template<class InputIter>
inline label erase(InputIter begIter, InputIter endIter);
template<class InputIterator>
inline label erase(InputIterator begIter, InputIterator endIter);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
@ -223,8 +223,8 @@ public:
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
template<unsigned Size>
inline label erase(const FixedList<label, Size>& list);
template<unsigned N>
inline label erase(const FixedList<label, N>& list);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.

View File

@ -275,11 +275,11 @@ inline bool Foam::edge::insert(const label index)
}
template<class InputIter>
template<class InputIterator>
inline Foam::label Foam::edge::insert
(
InputIter begIter,
InputIter endIter
InputIterator begIter,
InputIterator endIter
)
{
// Available slots.
@ -305,8 +305,8 @@ inline Foam::label Foam::edge::insert(std::initializer_list<label> list)
}
template<unsigned Size>
inline Foam::label Foam::edge::insert(const FixedList<label, Size>& list)
template<unsigned N>
inline Foam::label Foam::edge::insert(const FixedList<label, N>& list)
{
return insert(list.begin(), list.end());
}
@ -344,11 +344,11 @@ inline Foam::label Foam::edge::erase(const label index)
}
template<class InputIter>
template<class InputIterator>
inline Foam::label Foam::edge::erase
(
InputIter begIter,
InputIter endIter
InputIterator begIter,
InputIterator endIter
)
{
// Occupied slots.
@ -371,8 +371,8 @@ inline Foam::label Foam::edge::erase(std::initializer_list<label> list)
}
template<unsigned Size>
inline Foam::label Foam::edge::erase(const FixedList<label, Size>& list)
template<unsigned N>
inline Foam::label Foam::edge::erase(const FixedList<label, N>& list)
{
return erase(list.begin(), list.end());
}

View File

@ -149,17 +149,17 @@ public:
inline explicit face(const label sz);
//- Copy construct from list of labels
inline explicit face(const labelUList& lst);
inline explicit face(const labelUList& list);
//- Copy construct from list of labels
template<unsigned Size>
inline explicit face(const FixedList<label, Size>& lst);
template<unsigned N>
inline explicit face(const FixedList<label, N>& list);
//- Copy construct from an initializer list of labels
inline explicit face(std::initializer_list<label> lst);
inline explicit face(std::initializer_list<label> list);
//- Move construct from list of labels
inline explicit face(labelList&& lst);
inline explicit face(labelList&& list);
//- Copy construct from triFace
face(const triFace& f);

View File

@ -51,28 +51,28 @@ inline Foam::face::face(const label sz)
{}
inline Foam::face::face(const labelUList& lst)
inline Foam::face::face(const labelUList& list)
:
labelList(lst)
labelList(list)
{}
template<unsigned Size>
inline Foam::face::face(const FixedList<label, Size>& lst)
template<unsigned N>
inline Foam::face::face(const FixedList<label, N>& list)
:
labelList(lst)
labelList(list)
{}
inline Foam::face::face(std::initializer_list<label> lst)
inline Foam::face::face(std::initializer_list<label> list)
:
labelList(lst)
labelList(list)
{}
inline Foam::face::face(labelList&& lst)
inline Foam::face::face(labelList&& list)
:
labelList(std::move(lst))
labelList(std::move(list))
{}

View File

@ -121,8 +121,8 @@ public:
}
//- Operate on a triangle or tetrahedron
template<unsigned Size>
result operator()(const FixedList<point, Size>& p) const
template<unsigned N>
result operator()(const FixedList<point, N>& p) const
{
return result();
}
@ -309,7 +309,7 @@ public:
Class listOp Declaration
\*---------------------------------------------------------------------------*/
template<unsigned Size>
template<unsigned N>
class listOp
:
public uniformOp<zero::null>
@ -321,16 +321,16 @@ public:
//- Result class
class result
:
public DynamicList<FixedList<point, Size>>
public DynamicList<FixedList<point, N>>
{
public:
// Constructors
//- Construct from a single element
result(const FixedList<point, Size>& x)
result(const FixedList<point, N>& x)
:
DynamicList<FixedList<point, Size>>(1, x)
DynamicList<FixedList<point, N>>(1, x)
{}
@ -368,7 +368,7 @@ public:
}
//- Operate on a triangle or tetrahedron
result operator()(const FixedList<point, Size>& p) const
result operator()(const FixedList<point, N>& p) const
{
return result(p);
}
@ -420,8 +420,8 @@ public:
}
//- Operate on a triangle or tetrahedron
template<unsigned Size>
result operator()(const FixedList<point, Size>& p) const
template<unsigned N>
result operator()(const FixedList<point, N>& p) const
{
this->data().append(p);
return result();

View File

@ -129,10 +129,10 @@ inline const cut::uniformOp<Type>& tetCutPrism23
//- Modify a fixed list for reordering a tri (does nothing)
template<class Type, unsigned Size>
template<class Type, unsigned N>
inline FixedList<Type, 3> triReorder
(
const FixedList<Type, Size>& x,
const FixedList<Type, N>& x,
const FixedList<label, 3>& indices
)
{
@ -182,10 +182,10 @@ inline FixedList<Type, 4> triCutQuad
//- Modify a fixed list for reordering a tet (does nothing)
template<class Type, unsigned Size>
template<class Type, unsigned N>
inline FixedList<Type, 4> tetReorder
(
const FixedList<Type, Size>& x,
const FixedList<Type, N>& x,
const FixedList<label, 4>& indices
)
{

View File

@ -176,11 +176,11 @@ public:
//- Construct as subset of points
// The indices could be from edge/triFace etc.
// Local processor domain only (no reduce as in boundBox)
template<unsigned Size>
template<unsigned N>
treeBoundBox
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
);

View File

@ -28,11 +28,11 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<unsigned Size>
template<unsigned N>
Foam::treeBoundBox::treeBoundBox
(
const UList<point>& points,
const FixedList<label, Size>& indices
const FixedList<label, N>& indices
)
:
boundBox(points, indices, false)

View File

@ -120,11 +120,11 @@ namespace vtk
//- Write a list of values.
// The output does not include the payload size.
template<class Type, unsigned Size>
template<class Type, unsigned N>
void writeList
(
vtk::formatter& fmt,
const FixedList<Type, Size>& values
const FixedList<Type, N>& values
);

View File

@ -57,11 +57,11 @@ void Foam::vtk::writeList
}
template<class Type, unsigned Size>
template<class Type, unsigned N>
void Foam::vtk::writeList
(
vtk::formatter& fmt,
const FixedList<Type, Size>& values
const FixedList<Type, N>& values
)
{
for (const Type& val : values)