mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: consistent indentation and template parameters for FixedList
This commit is contained in:
@ -42,11 +42,11 @@ See also
|
|||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
Ostream& printInfo(const FixedList<List<T>, Size>& list)
|
Ostream& printInfo(const FixedList<List<T>, N>& list)
|
||||||
{
|
{
|
||||||
Info<< list << " addresses:";
|
Info<< list << " addresses:";
|
||||||
for (unsigned i = 0; i < Size; ++i)
|
for (unsigned i = 0; i < N; ++i)
|
||||||
{
|
{
|
||||||
Info<< " " << long(list[i].cdata());
|
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
|
Ostream& printInfo
|
||||||
(
|
(
|
||||||
const FixedList<List<T>, Size>& list1,
|
const FixedList<List<T>, N>& list1,
|
||||||
const FixedList<List<T>, Size>& list2
|
const FixedList<List<T>, N>& list2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "llist1:"; printInfo(list1);
|
Info<< "llist1:"; printInfo(list1);
|
||||||
@ -139,15 +139,15 @@ int main(int argc, char *argv[])
|
|||||||
FixedList<label, 4> list1{2, 3, 4, 5};
|
FixedList<label, 4> list1{2, 3, 4, 5};
|
||||||
|
|
||||||
Info<< "list1:" << list1
|
Info<< "list1:" << list1
|
||||||
<< " hash:" << FixedList<label,4>::Hash<>()(list1) << nl
|
<< " hash:" << FixedList<label, 4>::Hash<>()(list1) << nl
|
||||||
<< " hash:" << Hash<FixedList<label,4>>()(list1) << nl;
|
<< " hash:" << Hash<FixedList<label, 4>>()(list1) << nl;
|
||||||
|
|
||||||
label a[4] = {0, 1, 2, 3};
|
label a[4] = {0, 1, 2, 3};
|
||||||
FixedList<label, 4> list2(a);
|
FixedList<label, 4> list2(a);
|
||||||
|
|
||||||
Info<< "list2:" << list2
|
Info<< "list2:" << list2
|
||||||
<< " hash:" << FixedList<label,4>::Hash<>()(list2) << nl
|
<< " hash:" << FixedList<label, 4>::Hash<>()(list2) << nl
|
||||||
<< " hash:" << Hash<FixedList<label,4>>()(list2) << nl;
|
<< " hash:" << Hash<FixedList<label, 4>>()(list2) << nl;
|
||||||
|
|
||||||
|
|
||||||
// Using FixedList for content too
|
// Using FixedList for content too
|
||||||
|
|||||||
@ -57,8 +57,8 @@ inline Foam::label Foam::HashSet<Key, Hash>::assignMany
|
|||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& list)
|
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, N>& list)
|
||||||
:
|
:
|
||||||
parent_type(2*list.size())
|
parent_type(2*list.size())
|
||||||
{
|
{
|
||||||
@ -154,10 +154,10 @@ inline Foam::label Foam::HashSet<Key, Hash>::insert
|
|||||||
|
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline Foam::label Foam::HashSet<Key, Hash>::insert
|
inline Foam::label Foam::HashSet<Key, Hash>::insert
|
||||||
(
|
(
|
||||||
const FixedList<Key, Size>& list
|
const FixedList<Key, N>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return insert(list.begin(), list.end());
|
return insert(list.begin(), list.end());
|
||||||
@ -207,10 +207,10 @@ inline Foam::label Foam::HashSet<Key, Hash>::unset
|
|||||||
|
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline Foam::label Foam::HashSet<Key, Hash>::unset
|
inline Foam::label Foam::HashSet<Key, Hash>::unset
|
||||||
(
|
(
|
||||||
const FixedList<Key, Size>& list
|
const FixedList<Key, N>& list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return unset(list.begin(), list.end());
|
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<class Key, class Hash>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& rhs)
|
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, N>& rhs)
|
||||||
{
|
{
|
||||||
assignMany(rhs.size(), rhs.begin(), rhs.end());
|
assignMany(rhs.size(), rhs.begin(), rhs.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,8 +134,8 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from FixedList of Key
|
//- Construct from FixedList of Key
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
explicit HashSet(const FixedList<Key, Size>& list);
|
explicit HashSet(const FixedList<Key, N>& list);
|
||||||
|
|
||||||
//- Construct from UList of Key
|
//- Construct from UList of Key
|
||||||
explicit HashSet(const UList<Key>& list);
|
explicit HashSet(const UList<Key>& list);
|
||||||
@ -203,8 +203,8 @@ public:
|
|||||||
|
|
||||||
//- Insert keys from the list of Key
|
//- Insert keys from the list of Key
|
||||||
// \return The number of new elements inserted
|
// \return The number of new elements inserted
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline label insert(const FixedList<Key, Size>& list);
|
inline label insert(const FixedList<Key, N>& list);
|
||||||
|
|
||||||
//- Insert keys from the list of Key
|
//- Insert keys from the list of Key
|
||||||
// \return The number of new elements inserted
|
// \return The number of new elements inserted
|
||||||
@ -228,8 +228,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Same as insert (no value to overwrite)
|
//- Same as insert (no value to overwrite)
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline label set(const FixedList<Key, Size>& list)
|
inline label set(const FixedList<Key, N>& list)
|
||||||
{
|
{
|
||||||
return insert(list);
|
return insert(list);
|
||||||
}
|
}
|
||||||
@ -265,8 +265,8 @@ public:
|
|||||||
|
|
||||||
//- Unset the listed keys - same as erase
|
//- Unset the listed keys - same as erase
|
||||||
// \return The number of items removed
|
// \return The number of items removed
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline label unset(const FixedList<Key, Size>& list);
|
inline label unset(const FixedList<Key, N>& list);
|
||||||
|
|
||||||
//- Unset the listed keys - same as erase
|
//- Unset the listed keys - same as erase
|
||||||
// \return The number of items removed
|
// \return The number of items removed
|
||||||
@ -338,8 +338,8 @@ public:
|
|||||||
void operator=(const UList<Key>& rhs);
|
void operator=(const UList<Key>& rhs);
|
||||||
|
|
||||||
//- Assignment from a FixedList of keys
|
//- Assignment from a FixedList of keys
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
void operator=(const FixedList<Key, Size>& rhs);
|
void operator=(const FixedList<Key, N>& rhs);
|
||||||
|
|
||||||
//- Assignment from an initializer list of keys
|
//- Assignment from an initializer list of keys
|
||||||
void operator=(std::initializer_list<Key> rhs);
|
void operator=(std::initializer_list<Key> rhs);
|
||||||
|
|||||||
@ -443,10 +443,10 @@ inline Foam::label Foam::HashTable<T, Key, Hash>::erase
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline Foam::label Foam::HashTable<T, Key, Hash>::erase
|
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());
|
return erase(keys.cbegin(), keys.cend());
|
||||||
|
|||||||
@ -99,7 +99,7 @@ namespace Foam
|
|||||||
|
|
||||||
template<class T> class List;
|
template<class T> class List;
|
||||||
template<class T> class UList;
|
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> class HashTable;
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
@ -406,8 +406,8 @@ public:
|
|||||||
|
|
||||||
//- Remove table entries given by the listed keys
|
//- Remove table entries given by the listed keys
|
||||||
// \return The number of items removed
|
// \return The number of items removed
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline label erase(const FixedList<Key, Size>& keys);
|
inline label erase(const FixedList<Key, N>& keys);
|
||||||
|
|
||||||
//- Remove table entries given by the listed keys
|
//- Remove table entries given by the listed keys
|
||||||
// \return The number of items removed
|
// \return The number of items removed
|
||||||
|
|||||||
@ -138,8 +138,8 @@ public:
|
|||||||
inline explicit DynamicList(const UList<T>& lst);
|
inline explicit DynamicList(const UList<T>& lst);
|
||||||
|
|
||||||
//- Construct from a FixedList
|
//- Construct from a FixedList
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
inline DynamicList(const FixedList<T, FixedSize>& lst);
|
inline DynamicList(const FixedList<T, N>& lst);
|
||||||
|
|
||||||
//- Construct given begin/end iterators.
|
//- Construct given begin/end iterators.
|
||||||
// Uses std::distance to determine the size.
|
// Uses std::distance to determine the size.
|
||||||
@ -249,9 +249,9 @@ public:
|
|||||||
inline DynamicList<T, SizeMin>& append(const UList<T>& lst);
|
inline DynamicList<T, SizeMin>& append(const UList<T>& lst);
|
||||||
|
|
||||||
//- Append a FixedList to the end of this list.
|
//- Append a FixedList to the end of this list.
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
inline DynamicList<T, SizeMin>&
|
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.
|
//- Append an initializer list at the end of this list.
|
||||||
inline DynamicList<T, SizeMin>&
|
inline DynamicList<T, SizeMin>&
|
||||||
@ -323,8 +323,8 @@ public:
|
|||||||
inline void operator=(const UList<T>& lst);
|
inline void operator=(const UList<T>& lst);
|
||||||
|
|
||||||
//- Assignment to FixedList
|
//- Assignment to FixedList
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
inline void operator=(const FixedList<T, FixedSize>& lst);
|
inline void operator=(const FixedList<T, N>& lst);
|
||||||
|
|
||||||
//- Assignment to DynamicList
|
//- Assignment to DynamicList
|
||||||
inline void operator=(const DynamicList<T, SizeMin>& lst);
|
inline void operator=(const DynamicList<T, SizeMin>& lst);
|
||||||
|
|||||||
@ -130,10 +130,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||||
(
|
(
|
||||||
const FixedList<T, FixedSize>& lst
|
const FixedList<T, N>& lst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
capacity_(0)
|
capacity_(0)
|
||||||
@ -515,11 +515,11 @@ Foam::DynamicList<T, SizeMin>::append
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
inline Foam::DynamicList<T, SizeMin>&
|
inline Foam::DynamicList<T, SizeMin>&
|
||||||
Foam::DynamicList<T, SizeMin>::append
|
Foam::DynamicList<T, SizeMin>::append
|
||||||
(
|
(
|
||||||
const FixedList<T, FixedSize>& lst
|
const FixedList<T, N>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label idx = List<T>::size();
|
label idx = List<T>::size();
|
||||||
@ -770,10 +770,10 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
|||||||
|
|
||||||
|
|
||||||
template<class T, int SizeMin>
|
template<class T, int SizeMin>
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
inline void Foam::DynamicList<T, SizeMin>::operator=
|
inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||||
(
|
(
|
||||||
const FixedList<T, FixedSize>& lst
|
const FixedList<T, N>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label n = lst.size();
|
const label n = lst.size();
|
||||||
|
|||||||
@ -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-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,8 +28,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
Foam::label Foam::FixedList<T, Size>::find
|
Foam::label Foam::FixedList<T, N>::find
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
const label start
|
const label start
|
||||||
@ -39,7 +39,7 @@ Foam::label Foam::FixedList<T, Size>::find
|
|||||||
{
|
{
|
||||||
List_CONST_ACCESS(T, *this, list);
|
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)
|
if (list[i] == val)
|
||||||
{
|
{
|
||||||
@ -52,8 +52,8 @@ Foam::label Foam::FixedList<T, Size>::find
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
void Foam::FixedList<T, Size>::moveFirst(const label i)
|
void Foam::FixedList<T, N>::moveFirst(const label i)
|
||||||
{
|
{
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
|
|
||||||
@ -64,20 +64,20 @@ void Foam::FixedList<T, Size>::moveFirst(const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
void Foam::FixedList<T, Size>::moveLast(const label i)
|
void Foam::FixedList<T, N>::moveLast(const label i)
|
||||||
{
|
{
|
||||||
checkIndex(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]);
|
Foam::Swap(v_[i], v_[upper]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
void Foam::FixedList<T, Size>::swapFirst(const label i)
|
void Foam::FixedList<T, N>::swapFirst(const label i)
|
||||||
{
|
{
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
|
|
||||||
@ -88,12 +88,12 @@ void Foam::FixedList<T, Size>::swapFirst(const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
void Foam::FixedList<T, Size>::swapLast(const label i)
|
void Foam::FixedList<T, N>::swapLast(const label i)
|
||||||
{
|
{
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
|
|
||||||
const label upper = label(Size - 1);
|
const label upper = label(N-1);
|
||||||
|
|
||||||
if (i < upper)
|
if (i < upper)
|
||||||
{
|
{
|
||||||
@ -104,14 +104,14 @@ void Foam::FixedList<T, Size>::swapLast(const label i)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& list) const
|
bool Foam::FixedList<T, N>::operator==(const FixedList<T, N>& list) const
|
||||||
{
|
{
|
||||||
List_CONST_ACCESS(T, *this, lhs);
|
List_CONST_ACCESS(T, *this, lhs);
|
||||||
List_CONST_ACCESS(T, (list), rhs);
|
List_CONST_ACCESS(T, (list), rhs);
|
||||||
|
|
||||||
// List sizes are identical by definition (template parameter)
|
// 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]))
|
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>
|
template<class T, unsigned N>
|
||||||
bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& list) const
|
bool Foam::FixedList<T, N>::operator<(const FixedList<T, N>& list) const
|
||||||
{
|
{
|
||||||
List_CONST_ACCESS(T, *this, lhs);
|
List_CONST_ACCESS(T, *this, lhs);
|
||||||
List_CONST_ACCESS(T, (list), rhs);
|
List_CONST_ACCESS(T, (list), rhs);
|
||||||
|
|
||||||
// List sizes are identical by definition (template parameter)
|
// 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])
|
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>
|
template<class T, unsigned N>
|
||||||
bool Foam::FixedList<T, Size>::operator!=(const FixedList<T, Size>& list) const
|
bool Foam::FixedList<T, N>::operator!=(const FixedList<T, N>& list) const
|
||||||
{
|
{
|
||||||
return !operator==(list);
|
return !operator==(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
bool Foam::FixedList<T, Size>::operator>(const FixedList<T, Size>& list) const
|
bool Foam::FixedList<T, N>::operator>(const FixedList<T, N>& list) const
|
||||||
{
|
{
|
||||||
return list.operator<(*this);
|
return list.operator<(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
bool Foam::FixedList<T, Size>::operator<=(const FixedList<T, Size>& list) const
|
bool Foam::FixedList<T, N>::operator<=(const FixedList<T, N>& list) const
|
||||||
{
|
{
|
||||||
return !list.operator<(*this);
|
return !list.operator<(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
bool Foam::FixedList<T, Size>::operator>=(const FixedList<T, Size>& list) const
|
bool Foam::FixedList<T, N>::operator>=(const FixedList<T, N>& list) const
|
||||||
{
|
{
|
||||||
return !operator<(list);
|
return !operator<(list);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) 2017-2018 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,7 +25,7 @@ Class
|
|||||||
Foam::FixedList
|
Foam::FixedList
|
||||||
|
|
||||||
Description
|
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
|
SourceFiles
|
||||||
FixedList.C
|
FixedList.C
|
||||||
@ -57,36 +57,32 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// 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>&);
|
|
||||||
|
|
||||||
|
template<class T, unsigned N> class FixedList;
|
||||||
template<class T> class UList;
|
template<class T> class UList;
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
Istream& operator>>(Istream& is, FixedList<T, N>& list);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class FixedList Declaration
|
Class FixedList Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
class FixedList
|
class FixedList
|
||||||
{
|
{
|
||||||
static_assert
|
static_assert
|
||||||
(
|
(
|
||||||
Size && Size <= std::numeric_limits<int>::max(),
|
N && N <= std::numeric_limits<int>::max(),
|
||||||
"Size must be positive (non-zero) and also fit as a signed value"
|
"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.
|
//- Vector of values of type T of length N.
|
||||||
T v_[Size];
|
T v_[N];
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -100,6 +96,7 @@ protected:
|
|||||||
//- Write the FixedList with its compound type
|
//- Write the FixedList with its compound type
|
||||||
void writeEntry(Ostream& os) const;
|
void writeEntry(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// STL type definitions
|
// STL type definitions
|
||||||
@ -141,7 +138,7 @@ public:
|
|||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
|
|
||||||
//- Return a null FixedList
|
//- Return a null FixedList
|
||||||
inline static const FixedList<T, Size>& null();
|
inline static const FixedList<T, N>& null();
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -156,14 +153,14 @@ public:
|
|||||||
inline explicit FixedList(const zero);
|
inline explicit FixedList(const zero);
|
||||||
|
|
||||||
//- Copy construct from C-array
|
//- Copy construct from C-array
|
||||||
inline explicit FixedList(const T list[Size]);
|
inline explicit FixedList(const T list[N]);
|
||||||
|
|
||||||
//- Copy constructor
|
//- 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
|
//- Move construct by using move assignment for the individual
|
||||||
//- list elements
|
//- list elements
|
||||||
inline FixedList(FixedList<T, Size>&& list);
|
inline FixedList(FixedList<T, N>&& list);
|
||||||
|
|
||||||
//- Construct given begin/end iterators
|
//- Construct given begin/end iterators
|
||||||
// Uses std::distance when verifying the size.
|
// Uses std::distance when verifying the size.
|
||||||
@ -183,67 +180,67 @@ public:
|
|||||||
explicit FixedList(Istream& is);
|
explicit FixedList(Istream& is);
|
||||||
|
|
||||||
//- Clone
|
//- Clone
|
||||||
inline autoPtr<FixedList<T, Size>> clone() const;
|
inline autoPtr<FixedList<T, N>> clone() const;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return the forward circular index, i.e. next index
|
//- Return a const pointer to the first data element.
|
||||||
//- which returns to the first at the end of the list
|
// Similar to the STL front() method and the string::data() method
|
||||||
inline label fcIndex(const label i) const;
|
// 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)
|
//- Return a pointer to the first data element.
|
||||||
inline const T& fcValue(const label i) const;
|
// 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)
|
//- Return the first element of the list
|
||||||
inline T& fcValue(const label i);
|
inline T& first();
|
||||||
|
|
||||||
//- Return the reverse circular index, i.e. previous index
|
//- Return first element of the list
|
||||||
//- which returns to the last at the beginning of the list
|
inline const T& first() const;
|
||||||
inline label rcIndex(const label i) const;
|
|
||||||
|
|
||||||
//- Return reverse circular value (ie, previous value in the list)
|
//- Return the last element of the list
|
||||||
inline const T& rcValue(const label i) const;
|
inline T& last();
|
||||||
|
|
||||||
//- Return reverse circular value (ie, previous value in the list)
|
//- Return the last element of the list
|
||||||
inline T& rcValue(const label i);
|
inline const T& last() const;
|
||||||
|
|
||||||
|
|
||||||
//- Return a const pointer to the first data element.
|
//- Return the forward circular index, i.e. next index
|
||||||
// Similar to the STL front() method and the string::data() method
|
//- which returns to the first at the end of the list
|
||||||
// This can be used (with caution) when interfacing with C code
|
inline label fcIndex(const label i) const;
|
||||||
inline const T* cdata() const;
|
|
||||||
|
|
||||||
//- Return a pointer to the first data element.
|
//- Return forward circular value (ie, next value in the list)
|
||||||
// Similar to the STL front() method and the string::data() method
|
inline const T& fcValue(const label i) const;
|
||||||
// This can be used (with caution) when interfacing with C code
|
|
||||||
inline T* data();
|
|
||||||
|
|
||||||
//- Return the first element of the list
|
//- Return forward circular value (ie, next value in the list)
|
||||||
inline T& first();
|
inline T& fcValue(const label i);
|
||||||
|
|
||||||
//- Return first element of the list
|
//- Return the reverse circular index, i.e. previous index
|
||||||
inline const T& first() const;
|
//- 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
|
//- Return reverse circular value (ie, previous value in the list)
|
||||||
inline T& last();
|
inline const T& rcValue(const label i) const;
|
||||||
|
|
||||||
//- Return the last element of the list
|
//- Return reverse circular value (ie, previous value in the list)
|
||||||
inline const T& last() const;
|
inline T& rcValue(const label i);
|
||||||
|
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
|
|
||||||
//- Check start is within valid range [0,size)
|
//- Check start is within valid range [0,size)
|
||||||
inline void checkStart(const label start) const;
|
inline void checkStart(const label start) const;
|
||||||
|
|
||||||
//- Check size is identical to Size template parameter
|
//- Check size is identical to template parameter N
|
||||||
inline void checkSize(const label size) const;
|
inline void checkSize(const label size) const;
|
||||||
|
|
||||||
//- Check index is within valid range [0,size)
|
//- Check index is within valid range [0,N)
|
||||||
inline void checkIndex(const label i) const;
|
inline void checkIndex(const label i) const;
|
||||||
|
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
@ -259,12 +256,10 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Dummy resize function
|
//- Dummy resize function, to make FixedList consistent with List
|
||||||
// needed to make FixedList consistent with List
|
|
||||||
inline void resize(const label n);
|
inline void resize(const label n);
|
||||||
|
|
||||||
//- Dummy setSize function
|
//- Dummy setSize function, to make FixedList consistent with List
|
||||||
// needed to make FixedList consistent with List
|
|
||||||
inline void setSize(const label n);
|
inline void setSize(const label n);
|
||||||
|
|
||||||
//- Move element to the first position.
|
//- Move element to the first position.
|
||||||
@ -281,7 +276,7 @@ public:
|
|||||||
|
|
||||||
//- Transfer by swapping using a move assignment for the content
|
//- Transfer by swapping using a move assignment for the content
|
||||||
//- of the individual list elements
|
//- of the individual list elements
|
||||||
inline void transfer(FixedList<T, Size>& list);
|
inline void transfer(FixedList<T, N>& list);
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
@ -293,7 +288,7 @@ public:
|
|||||||
inline const T& operator[](const label i) const;
|
inline const T& operator[](const label i) const;
|
||||||
|
|
||||||
//- Assignment to array operator. Takes linear time
|
//- 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
|
//- Assignment to UList operator. Takes linear time
|
||||||
inline void operator=(const UList<T>& list);
|
inline void operator=(const UList<T>& list);
|
||||||
@ -308,10 +303,10 @@ public:
|
|||||||
inline void operator=(const T& val);
|
inline void operator=(const T& val);
|
||||||
|
|
||||||
//- Copy assignment
|
//- Copy assignment
|
||||||
inline void operator=(const FixedList<T, Size>& list);
|
inline void operator=(const FixedList<T, N>& list);
|
||||||
|
|
||||||
//- Move assignment
|
//- Move assignment
|
||||||
inline void operator=(FixedList<T, Size>&& list);
|
inline void operator=(FixedList<T, N>&& list);
|
||||||
|
|
||||||
|
|
||||||
// Random access iterator (non-const)
|
// Random access iterator (non-const)
|
||||||
@ -374,7 +369,7 @@ public:
|
|||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
//- Swap lists by swapping the content of the individual list elements
|
//- 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
|
// STL member operators
|
||||||
@ -382,49 +377,42 @@ public:
|
|||||||
//- Equality operation on FixedLists of the same type.
|
//- Equality operation on FixedLists of the same type.
|
||||||
// Returns true when the FixedLists are element-wise equal
|
// Returns true when the FixedLists are element-wise equal
|
||||||
// (using FixedList::value_type::operator==). Takes linear time
|
// (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
|
//- 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
|
//- 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
|
//- 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
|
//- 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
|
//- 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
|
// 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;
|
void writeEntry(const word& keyword, Ostream& os) const;
|
||||||
|
|
||||||
//- Write the List, with line-breaks in ASCII if the list length
|
//- Write the list, with line-breaks in ASCII if the length
|
||||||
//- exceeds shortListLen.
|
//- exceeds shortLen.
|
||||||
// Using '0' suppresses line-breaks entirely.
|
// 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
|
//- Read from Istream, discarding contents of existing List
|
||||||
friend Istream& operator>> <T, Size>
|
friend Istream& operator>> <T, N>
|
||||||
(
|
(
|
||||||
Istream& is,
|
Istream& is,
|
||||||
FixedList<T, Size>& list
|
FixedList<T, N>& list
|
||||||
);
|
|
||||||
|
|
||||||
//- Write to Ostream, as per writeList() with shortListLen=10
|
|
||||||
friend Ostream& operator<< <T, Size>
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const FixedList<T, Size>& list
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -438,13 +426,13 @@ public:
|
|||||||
{
|
{
|
||||||
inline unsigned operator()
|
inline unsigned operator()
|
||||||
(
|
(
|
||||||
const FixedList<T, Size>& obj,
|
const FixedList<T, N>& obj,
|
||||||
unsigned seed=0
|
unsigned seed=0
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (contiguous<T>())
|
if (contiguous<T>())
|
||||||
{
|
{
|
||||||
return Hasher(obj.cdata(), Size*sizeof(T), seed);
|
return Hasher(obj.cdata(), N*sizeof(T), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const T& val : obj)
|
for (const T& val : obj)
|
||||||
@ -461,8 +449,8 @@ public:
|
|||||||
|
|
||||||
//- Swap FixedList contents - see FixedList::swap().
|
//- Swap FixedList contents - see FixedList::swap().
|
||||||
// Internally this actually swaps the individual list elements
|
// Internally this actually swaps the individual list elements
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Swap(FixedList<T,Size>& lhs, FixedList<T,Size>& rhs);
|
inline void Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs);
|
||||||
|
|
||||||
|
|
||||||
//- Hashing for FixedList data, which uses Hasher for contiguous data and
|
//- 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
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "FixedListI.H"
|
#include "FixedListI.H"
|
||||||
|
|||||||
@ -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) 2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,16 +28,25 @@ License
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#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 * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline bool Foam::FixedList<T, Size>::uniform() const
|
inline bool Foam::FixedList<T, N>::uniform() const
|
||||||
{
|
{
|
||||||
if (Size > 1)
|
if (N > 1)
|
||||||
{
|
{
|
||||||
const T& val = first();
|
const T& val = first();
|
||||||
|
|
||||||
for (unsigned i=1; i<Size; ++i)
|
for (unsigned i=1; i<N; ++i)
|
||||||
{
|
{
|
||||||
if (val != (*this)[i])
|
if (val != (*this)[i])
|
||||||
{
|
{
|
||||||
@ -54,59 +63,59 @@ inline bool Foam::FixedList<T, Size>::uniform() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(const T& val)
|
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;
|
v_[i] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(const zero)
|
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;
|
v_[i] = Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(const T list[Size])
|
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];
|
v_[i] = list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& list)
|
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];
|
v_[i] = list.v_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(FixedList<T, Size>&& list)
|
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]);
|
v_[i] = std::move(list.v_[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
template<class InputIterator>
|
template<class InputIterator>
|
||||||
inline Foam::FixedList<T, Size>::FixedList
|
inline Foam::FixedList<T, N>::FixedList
|
||||||
(
|
(
|
||||||
InputIterator begIter,
|
InputIterator begIter,
|
||||||
InputIterator endIter
|
InputIterator endIter
|
||||||
@ -114,22 +123,21 @@ inline Foam::FixedList<T, Size>::FixedList
|
|||||||
{
|
{
|
||||||
checkSize(std::distance(begIter, endIter));
|
checkSize(std::distance(begIter, endIter));
|
||||||
|
|
||||||
InputIterator iter = begIter;
|
for (unsigned i=0; i<N; ++i)
|
||||||
for (unsigned i=0; i<Size; ++i)
|
|
||||||
{
|
{
|
||||||
v_[i] = *iter;
|
v_[i] = *begIter;
|
||||||
++iter;
|
++begIter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(std::initializer_list<T> list)
|
inline Foam::FixedList<T, N>::FixedList(std::initializer_list<T> list)
|
||||||
{
|
{
|
||||||
checkSize(list.size());
|
checkSize(list.size());
|
||||||
|
|
||||||
auto iter = list.begin();
|
auto iter = list.begin();
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
v_[i] = *iter;
|
v_[i] = *iter;
|
||||||
++iter;
|
++iter;
|
||||||
@ -137,25 +145,25 @@ inline Foam::FixedList<T, Size>::FixedList(std::initializer_list<T> list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(const UList<T>& list)
|
inline Foam::FixedList<T, N>::FixedList(const UList<T>& list)
|
||||||
{
|
{
|
||||||
checkSize(list.size());
|
checkSize(list.size());
|
||||||
|
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
v_[i] = list[i];
|
v_[i] = list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& list)
|
inline Foam::FixedList<T, N>::FixedList(const SLList<T>& list)
|
||||||
{
|
{
|
||||||
checkSize(list.size());
|
checkSize(list.size());
|
||||||
|
|
||||||
auto iter = list.begin();
|
auto iter = list.begin();
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
v_[i] = *iter;
|
v_[i] = *iter;
|
||||||
++iter;
|
++iter;
|
||||||
@ -163,104 +171,141 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::autoPtr<Foam::FixedList<T, Size>>
|
inline Foam::autoPtr<Foam::FixedList<T, N>>
|
||||||
Foam::FixedList<T, Size>::clone() const
|
Foam::FixedList<T, N>::clone() const
|
||||||
{
|
{
|
||||||
return autoPtr<FixedList<T, Size>>::New(*this);
|
return autoPtr<FixedList<T, N>>::New(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
|
inline const T*
|
||||||
|
Foam::FixedList<T, N>::cdata() const
|
||||||
{
|
{
|
||||||
return NullObjectRef<FixedList<T, Size>>();
|
return v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
|
inline T*
|
||||||
|
Foam::FixedList<T, N>::data()
|
||||||
{
|
{
|
||||||
return (i == Size-1 ? 0 : i+1);
|
return v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline const T& Foam::FixedList<T, Size>::fcValue(const label i) const
|
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));
|
return this->operator[](this->fcIndex(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline T& Foam::FixedList<T, Size>::fcValue(const label i)
|
inline T& Foam::FixedList<T, N>::fcValue(const label i)
|
||||||
{
|
{
|
||||||
return this->operator[](this->fcIndex(i));
|
return this->operator[](this->fcIndex(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
|
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>
|
template<class T, unsigned N>
|
||||||
inline const T& Foam::FixedList<T, Size>::rcValue(const label i) const
|
inline const T& Foam::FixedList<T, N>::rcValue(const label i) const
|
||||||
{
|
{
|
||||||
return this->operator[](this->rcIndex(i));
|
return this->operator[](this->rcIndex(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline T& Foam::FixedList<T, Size>::rcValue(const label i)
|
inline T& Foam::FixedList<T, N>::rcValue(const label i)
|
||||||
{
|
{
|
||||||
return this->operator[](this->rcIndex(i));
|
return this->operator[](this->rcIndex(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::checkStart(const label start) const
|
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
|
// Note: always accept start=0, even for zero-sized lists
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "start " << start << " out of range [0," << Size << ")"
|
<< "start " << start << " out of range [0," << N << ")"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::checkSize(const label size) const
|
inline void Foam::FixedList<T, N>::checkSize(const label size) const
|
||||||
{
|
{
|
||||||
if (unsigned(size) != Size)
|
if (unsigned(size) != N)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "size " << size << " != " << Size
|
<< "size " << size << " != " << N
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::checkIndex(const label i) const
|
inline void Foam::FixedList<T, N>::checkIndex(const label i) const
|
||||||
{
|
{
|
||||||
if (i < 0 || unsigned(i) >= Size)
|
if (i < 0 || unsigned(i) >= N)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "index " << i << " out of range [0," << Size << ")"
|
<< "index " << i << " out of range [0," << N << ")"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline bool Foam::FixedList<T, Size>::found
|
inline bool Foam::FixedList<T, N>::found
|
||||||
(
|
(
|
||||||
const T& val,
|
const T& val,
|
||||||
const label start
|
const label start
|
||||||
@ -270,16 +315,16 @@ inline bool Foam::FixedList<T, Size>::found
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::resize(const label n)
|
inline void Foam::FixedList<T, N>::resize(const label n)
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
checkSize(n);
|
checkSize(n);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::setSize(const label n)
|
inline void Foam::FixedList<T, N>::setSize(const label n)
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
checkSize(n);
|
checkSize(n);
|
||||||
@ -287,74 +332,30 @@ inline void Foam::FixedList<T, Size>::setSize(const label n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& list)
|
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]);
|
Foam::Swap(v_[i], list.v_[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::transfer(FixedList<T, Size>& list)
|
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]);
|
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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
inline T& Foam::FixedList<T, N>::operator[](const label i)
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
@ -363,8 +364,8 @@ inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
inline const T& Foam::FixedList<T, N>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
@ -373,76 +374,76 @@ inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(const T list[Size])
|
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];
|
v_[i] = list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(const UList<T>& list)
|
inline void Foam::FixedList<T, N>::operator=(const UList<T>& list)
|
||||||
{
|
{
|
||||||
checkSize(list.size());
|
checkSize(list.size());
|
||||||
|
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
v_[i] = list[i];
|
v_[i] = list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(const SLList<T>& list)
|
inline void Foam::FixedList<T, N>::operator=(const SLList<T>& list)
|
||||||
{
|
{
|
||||||
checkSize(list.size());
|
checkSize(list.size());
|
||||||
|
|
||||||
auto iter = list.begin();
|
auto iter = list.begin();
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
v_[i] = *iter;
|
v_[i] = *iter;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(std::initializer_list<T> list)
|
inline void Foam::FixedList<T, N>::operator=(std::initializer_list<T> list)
|
||||||
{
|
{
|
||||||
checkSize(list.size());
|
checkSize(list.size());
|
||||||
|
|
||||||
auto iter = list.begin();
|
auto iter = list.begin();
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
v_[i] = *iter;
|
v_[i] = *iter;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(const T& val)
|
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;
|
v_[i] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(const FixedList<T, Size>& list)
|
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];
|
v_[i] = list.v_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::FixedList<T, Size>::operator=(FixedList<T, Size>&& list)
|
inline void Foam::FixedList<T, N>::operator=(FixedList<T, N>&& list)
|
||||||
{
|
{
|
||||||
// No significant speedup observed for copy assignment on simple types,
|
// No significant speedup observed for copy assignment on simple types,
|
||||||
// use move assignment for generality with more complex 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]);
|
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 * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::iterator
|
inline typename Foam::FixedList<T, N>::iterator
|
||||||
Foam::FixedList<T, Size>::begin()
|
Foam::FixedList<T, N>::begin()
|
||||||
{
|
{
|
||||||
return v_;
|
return v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
inline typename Foam::FixedList<T, N>::const_iterator
|
||||||
Foam::FixedList<T, Size>::begin() const
|
Foam::FixedList<T, N>::begin() const
|
||||||
{
|
{
|
||||||
return v_;
|
return v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
inline typename Foam::FixedList<T, N>::const_iterator
|
||||||
Foam::FixedList<T, Size>::cbegin() const
|
Foam::FixedList<T, N>::cbegin() const
|
||||||
{
|
{
|
||||||
return v_;
|
return v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::iterator
|
inline typename Foam::FixedList<T, N>::iterator
|
||||||
Foam::FixedList<T, Size>::end()
|
Foam::FixedList<T, N>::end()
|
||||||
{
|
{
|
||||||
return (v_ + Size);
|
return (v_ + N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
inline typename Foam::FixedList<T, N>::const_iterator
|
||||||
Foam::FixedList<T, Size>::end() const
|
Foam::FixedList<T, N>::end() const
|
||||||
{
|
{
|
||||||
return (v_ + Size);
|
return (v_ + N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
inline typename Foam::FixedList<T, N>::const_iterator
|
||||||
Foam::FixedList<T, Size>::cend() const
|
Foam::FixedList<T, N>::cend() const
|
||||||
{
|
{
|
||||||
return (v_ + Size);
|
return (v_ + N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::reverse_iterator
|
inline typename Foam::FixedList<T, N>::reverse_iterator
|
||||||
Foam::FixedList<T, Size>::rbegin()
|
Foam::FixedList<T, N>::rbegin()
|
||||||
{
|
{
|
||||||
return reverse_iterator(end());
|
return reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
|
inline typename Foam::FixedList<T, N>::const_reverse_iterator
|
||||||
Foam::FixedList<T, Size>::rbegin() const
|
Foam::FixedList<T, N>::rbegin() const
|
||||||
{
|
{
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
|
inline typename Foam::FixedList<T, N>::const_reverse_iterator
|
||||||
Foam::FixedList<T, Size>::crbegin() const
|
Foam::FixedList<T, N>::crbegin() const
|
||||||
{
|
{
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::reverse_iterator
|
inline typename Foam::FixedList<T, N>::reverse_iterator
|
||||||
Foam::FixedList<T, Size>::rend()
|
Foam::FixedList<T, N>::rend()
|
||||||
{
|
{
|
||||||
return reverse_iterator(begin());
|
return reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
|
inline typename Foam::FixedList<T, N>::const_reverse_iterator
|
||||||
Foam::FixedList<T, Size>::rend() const
|
Foam::FixedList<T, N>::rend() const
|
||||||
{
|
{
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline typename Foam::FixedList<T, Size>::const_reverse_iterator
|
inline typename Foam::FixedList<T, N>::const_reverse_iterator
|
||||||
Foam::FixedList<T, Size>::crend() const
|
Foam::FixedList<T, N>::crend() const
|
||||||
{
|
{
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::size() const
|
inline Foam::label Foam::FixedList<T, N>::size() const
|
||||||
{
|
{
|
||||||
return Size;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::max_size() const
|
inline Foam::label Foam::FixedList<T, N>::max_size() const
|
||||||
{
|
{
|
||||||
return Size;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline bool Foam::FixedList<T, Size>::empty() const
|
inline bool Foam::FixedList<T, N>::empty() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -570,8 +571,8 @@ inline bool Foam::FixedList<T, Size>::empty() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
inline void Foam::Swap(FixedList<T, Size>& lhs, FixedList<T, Size>& rhs)
|
inline void Foam::Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs)
|
||||||
{
|
{
|
||||||
lhs.swap(rhs);
|
lhs.swap(rhs);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) 2017-2018 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,23 +31,22 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
void Foam::FixedList<T, Size>::writeEntry(Ostream& os) const
|
void Foam::FixedList<T, N>::writeEntry(Ostream& os) const
|
||||||
{
|
{
|
||||||
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
|
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
|
||||||
if (token::compound::isCompound(tag))
|
if (token::compound::isCompound(tag))
|
||||||
{
|
{
|
||||||
os << tag << ' ';
|
os << tag << ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
os << *this;
|
os << *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
void Foam::FixedList<T, Size>::writeEntry
|
void Foam::FixedList<T, N>::writeEntry
|
||||||
(
|
(
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
Ostream& os
|
Ostream& os
|
||||||
@ -59,34 +58,34 @@ void Foam::FixedList<T, Size>::writeEntry
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
Foam::Ostream& Foam::FixedList<T, Size>::writeList
|
Foam::Ostream& Foam::FixedList<T, N>::writeList
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const label shortListLen
|
const label shortListLen
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const FixedList<T, Size>& list = *this;
|
const FixedList<T, N>& list = *this;
|
||||||
|
|
||||||
// Write list contents depending on data format
|
// Write list contents depending on data format
|
||||||
|
|
||||||
// Unlike UList, no compact output form (eg, "2{-1}") since a
|
// Unlike UList, no compact output form since a FixedList is generally
|
||||||
// FixedList is generally small and we also want the same appearance
|
// small and we desire a consistent appearance.
|
||||||
// for FixedList<T, 2> as Tuple2<T,T>
|
// Eg, FixedList<T,2> or Pair<T> as "(-1 -1)", not as "2{-1}"
|
||||||
|
|
||||||
if (os.format() == IOstream::ASCII || !contiguous<T>())
|
if (os.format() == IOstream::ASCII || !contiguous<T>())
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
Size <= 1 || !shortListLen
|
N <= 1 || !shortListLen
|
||||||
|| (Size <= unsigned(shortListLen) && contiguous<T>())
|
|| (N <= unsigned(shortListLen) && contiguous<T>())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Start delimiter
|
// Start delimiter
|
||||||
os << token::BEGIN_LIST;
|
os << token::BEGIN_LIST;
|
||||||
|
|
||||||
// Contents
|
// Contents
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
if (i) os << token::SPACE;
|
if (i) os << token::SPACE;
|
||||||
os << list[i];
|
os << list[i];
|
||||||
@ -101,7 +100,7 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
|
|||||||
os << nl << token::BEGIN_LIST << nl;
|
os << nl << token::BEGIN_LIST << nl;
|
||||||
|
|
||||||
// Contents
|
// Contents
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
os << list[i] << nl;
|
os << list[i] << nl;
|
||||||
}
|
}
|
||||||
@ -115,7 +114,7 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
|
|||||||
// Binary, contiguous
|
// Binary, contiguous
|
||||||
|
|
||||||
// write(...) includes surrounding start/end delimiters
|
// 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);
|
os.check(FUNCTION_NAME);
|
||||||
@ -125,15 +124,15 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
Foam::FixedList<T, Size>::FixedList(Istream& is)
|
Foam::FixedList<T, N>::FixedList(Istream& is)
|
||||||
{
|
{
|
||||||
operator>>(is, *this);
|
operator>>(is, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned Size>
|
template<class T, unsigned N>
|
||||||
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
|
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
|
||||||
{
|
{
|
||||||
is.fatalCheck(FUNCTION_NAME);
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|
||||||
@ -143,7 +142,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
|
|||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, FixedList<T, Size>&) : "
|
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||||
"reading first token"
|
"reading first token"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -180,31 +179,31 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
|
|||||||
|
|
||||||
if (delimiter == token::BEGIN_LIST)
|
if (delimiter == token::BEGIN_LIST)
|
||||||
{
|
{
|
||||||
for (unsigned i=0; i<Size; ++i)
|
for (unsigned i=0; i<N; ++i)
|
||||||
{
|
{
|
||||||
is >> list[i];
|
is >> list[i];
|
||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, FixedList<T, Size>&) : "
|
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||||
"reading entry"
|
"reading entry"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
T element;
|
T val;
|
||||||
is >> element;
|
is >> val;
|
||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, FixedList<T, Size>&) : "
|
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||||
"reading the single entry"
|
"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
|
// 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
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, FixedList<T, Size>&) : "
|
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||||
"reading the binary block"
|
"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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -32,7 +32,6 @@ License
|
|||||||
#include "UIndirectList.H"
|
#include "UIndirectList.H"
|
||||||
#include "BiIndirectList.H"
|
#include "BiIndirectList.H"
|
||||||
#include "contiguous.H"
|
#include "contiguous.H"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -302,10 +301,10 @@ Foam::List<T>::List(InputIterator begIter, InputIterator endIter)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
Foam::List<T>::List(const FixedList<T, Size>& list)
|
Foam::List<T>::List(const FixedList<T, N>& list)
|
||||||
:
|
:
|
||||||
UList<T>(nullptr, Size)
|
UList<T>(nullptr, label(N))
|
||||||
{
|
{
|
||||||
doAlloc();
|
doAlloc();
|
||||||
copyList(list);
|
copyList(list);
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class Istream;
|
|||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
template<class T> class List;
|
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, int SizeMin> class DynamicList;
|
||||||
|
|
||||||
template<class T> class PtrList;
|
template<class T> class PtrList;
|
||||||
@ -160,9 +160,9 @@ public:
|
|||||||
template<class InputIterator>
|
template<class InputIterator>
|
||||||
List(InputIterator begIter, InputIterator endIter);
|
List(InputIterator begIter, InputIterator endIter);
|
||||||
|
|
||||||
//- Construct as copy of FixedList<T, Size>
|
//- Construct as copy of FixedList\<T, N\>
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
explicit List(const FixedList<T, Size>& list);
|
explicit List(const FixedList<T, N>& list);
|
||||||
|
|
||||||
//- Construct as copy of PtrList<T>
|
//- Construct as copy of PtrList<T>
|
||||||
explicit List(const PtrList<T>& list);
|
explicit List(const PtrList<T>& list);
|
||||||
|
|||||||
@ -225,16 +225,16 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Construct using data area from a FixedList
|
//- Construct using data area from a FixedList
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
UIListStream
|
UIListStream
|
||||||
(
|
(
|
||||||
const FixedList<char,FixedSize>& buffer,
|
const FixedList<char, N>& buffer,
|
||||||
streamFormat format=ASCII,
|
streamFormat format=ASCII,
|
||||||
versionNumber version=currentVersion,
|
versionNumber version=currentVersion,
|
||||||
const Foam::string& name="input"
|
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
|
//- Construct using data area from a List and number of bytes
|
||||||
|
|||||||
@ -210,15 +210,15 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct using data area from a FixedList
|
//- Construct using data area from a FixedList
|
||||||
template<unsigned FixedSize>
|
template<unsigned N>
|
||||||
UOListStream
|
UOListStream
|
||||||
(
|
(
|
||||||
FixedList<char,FixedSize>& buffer,
|
FixedList<char, N>& buffer,
|
||||||
streamFormat format=ASCII,
|
streamFormat format=ASCII,
|
||||||
versionNumber version=currentVersion
|
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
|
//- Construct using data area from a List and its inherent storage size
|
||||||
|
|||||||
@ -114,11 +114,11 @@ public:
|
|||||||
//- Construct bounding box as an indirect subset of the points.
|
//- Construct bounding box as an indirect subset of the points.
|
||||||
// The indices could be from edge/triFace etc.
|
// The indices could be from edge/triFace etc.
|
||||||
// Does parallel communication (doReduce = true)
|
// Does parallel communication (doReduce = true)
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
boundBox
|
boundBox
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices,
|
const FixedList<label, N>& indices,
|
||||||
bool doReduce = true
|
bool doReduce = true
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -202,16 +202,16 @@ public:
|
|||||||
inline void add(const tmp<pointField>& tpoints);
|
inline void add(const tmp<pointField>& tpoints);
|
||||||
|
|
||||||
//- Extend to include the points.
|
//- Extend to include the points.
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
void add(const FixedList<point, Size>& points);
|
void add(const FixedList<point, N>& points);
|
||||||
|
|
||||||
//- Extend to include a (subsetted) point field.
|
//- Extend to include a (subsetted) point field.
|
||||||
// The indices could be from edge/triFace etc.
|
// The indices could be from edge/triFace etc.
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Extend to include a (subsetted) point field.
|
//- Extend to include a (subsetted) point field.
|
||||||
@ -266,11 +266,11 @@ public:
|
|||||||
bool contains(const UList<point>& points) const;
|
bool contains(const UList<point>& points) const;
|
||||||
|
|
||||||
//- Contains all of the (subsetted) points? (inside or on edge)
|
//- Contains all of the (subsetted) points? (inside or on edge)
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
bool contains
|
bool contains
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -290,11 +290,11 @@ public:
|
|||||||
bool containsAny(const UList<point>& points) const;
|
bool containsAny(const UList<point>& points) const;
|
||||||
|
|
||||||
//- Contains any of the (subsetted) points? (inside or on edge)
|
//- Contains any of the (subsetted) points? (inside or on edge)
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
bool containsAny
|
bool containsAny
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Contains any of the (subsetted) points? (inside or on edge)
|
//- Contains any of the (subsetted) points? (inside or on edge)
|
||||||
|
|||||||
@ -28,11 +28,11 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
Foam::boundBox::boundBox
|
Foam::boundBox::boundBox
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices,
|
const FixedList<label, N>& indices,
|
||||||
bool doReduce
|
bool doReduce
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
@ -49,10 +49,10 @@ Foam::boundBox::boundBox
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
void Foam::boundBox::add
|
void Foam::boundBox::add
|
||||||
(
|
(
|
||||||
const FixedList<point, Size>& points
|
const FixedList<point, N>& points
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (const point& p : points)
|
for (const point& p : points)
|
||||||
@ -62,11 +62,11 @@ void Foam::boundBox::add
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
void Foam::boundBox::add
|
void Foam::boundBox::add
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label len = points.size();
|
const label len = points.size();
|
||||||
@ -108,11 +108,11 @@ void Foam::boundBox::add
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline bool Foam::boundBox::contains
|
inline bool Foam::boundBox::contains
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label len = points.size();
|
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
|
inline bool Foam::boundBox::containsAny
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label len = points.size();
|
const label len = points.size();
|
||||||
|
|||||||
@ -185,8 +185,8 @@ public:
|
|||||||
inline bool insert(const label index);
|
inline bool insert(const label index);
|
||||||
|
|
||||||
//- Insert values, using begin/end iterators.
|
//- Insert values, using begin/end iterators.
|
||||||
template<class InputIter>
|
template<class InputIterator>
|
||||||
inline label insert(InputIter begIter, InputIter endIter);
|
inline label insert(InputIterator begIter, InputIterator endIter);
|
||||||
|
|
||||||
//- Fill open slots with the indices if they did not previously exist.
|
//- Fill open slots with the indices if they did not previously exist.
|
||||||
// Returns true on success. Negative labels never insert.
|
// Returns true on success. Negative labels never insert.
|
||||||
@ -198,8 +198,8 @@ public:
|
|||||||
// Returns true on success. Negative labels never insert.
|
// Returns true on success. Negative labels never insert.
|
||||||
// Return the number of slots filled.
|
// Return the number of slots filled.
|
||||||
// Similar to a HashTable::insert().
|
// Similar to a HashTable::insert().
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline label insert(const FixedList<label, Size>& list);
|
inline label insert(const FixedList<label, N>& list);
|
||||||
|
|
||||||
//- Fill open slots with the indices if they did not previously exist.
|
//- Fill open slots with the indices if they did not previously exist.
|
||||||
// Returns true on success. Negative labels never insert.
|
// Returns true on success. Negative labels never insert.
|
||||||
@ -214,8 +214,8 @@ public:
|
|||||||
inline label erase(const label index);
|
inline label erase(const label index);
|
||||||
|
|
||||||
//- Remove values, using begin/end iterators.
|
//- Remove values, using begin/end iterators.
|
||||||
template<class InputIter>
|
template<class InputIterator>
|
||||||
inline label erase(InputIter begIter, InputIter endIter);
|
inline label erase(InputIterator begIter, InputIterator endIter);
|
||||||
|
|
||||||
//- Remove existing indices from the edge and set locations to '-1'.
|
//- Remove existing indices from the edge and set locations to '-1'.
|
||||||
// Returns the number of changes.
|
// Returns the number of changes.
|
||||||
@ -223,8 +223,8 @@ public:
|
|||||||
|
|
||||||
//- Remove existing indices from the edge and set locations to '-1'.
|
//- Remove existing indices from the edge and set locations to '-1'.
|
||||||
// Returns the number of changes.
|
// Returns the number of changes.
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline label erase(const FixedList<label, Size>& list);
|
inline label erase(const FixedList<label, N>& list);
|
||||||
|
|
||||||
//- Remove existing indices from the edge and set locations to '-1'.
|
//- Remove existing indices from the edge and set locations to '-1'.
|
||||||
// Returns the number of changes.
|
// Returns the number of changes.
|
||||||
|
|||||||
@ -275,11 +275,11 @@ inline bool Foam::edge::insert(const label index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class InputIter>
|
template<class InputIterator>
|
||||||
inline Foam::label Foam::edge::insert
|
inline Foam::label Foam::edge::insert
|
||||||
(
|
(
|
||||||
InputIter begIter,
|
InputIterator begIter,
|
||||||
InputIter endIter
|
InputIterator endIter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Available slots.
|
// Available slots.
|
||||||
@ -305,8 +305,8 @@ inline Foam::label Foam::edge::insert(std::initializer_list<label> list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline Foam::label Foam::edge::insert(const FixedList<label, Size>& list)
|
inline Foam::label Foam::edge::insert(const FixedList<label, N>& list)
|
||||||
{
|
{
|
||||||
return insert(list.begin(), list.end());
|
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
|
inline Foam::label Foam::edge::erase
|
||||||
(
|
(
|
||||||
InputIter begIter,
|
InputIterator begIter,
|
||||||
InputIter endIter
|
InputIterator endIter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Occupied slots.
|
// Occupied slots.
|
||||||
@ -371,8 +371,8 @@ inline Foam::label Foam::edge::erase(std::initializer_list<label> list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline Foam::label Foam::edge::erase(const FixedList<label, Size>& list)
|
inline Foam::label Foam::edge::erase(const FixedList<label, N>& list)
|
||||||
{
|
{
|
||||||
return erase(list.begin(), list.end());
|
return erase(list.begin(), list.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,17 +149,17 @@ public:
|
|||||||
inline explicit face(const label sz);
|
inline explicit face(const label sz);
|
||||||
|
|
||||||
//- Copy construct from list of labels
|
//- Copy construct from list of labels
|
||||||
inline explicit face(const labelUList& lst);
|
inline explicit face(const labelUList& list);
|
||||||
|
|
||||||
//- Copy construct from list of labels
|
//- Copy construct from list of labels
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
inline explicit face(const FixedList<label, Size>& lst);
|
inline explicit face(const FixedList<label, N>& list);
|
||||||
|
|
||||||
//- Copy construct from an initializer list of labels
|
//- 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
|
//- Move construct from list of labels
|
||||||
inline explicit face(labelList&& lst);
|
inline explicit face(labelList&& list);
|
||||||
|
|
||||||
//- Copy construct from triFace
|
//- Copy construct from triFace
|
||||||
face(const triFace& f);
|
face(const triFace& f);
|
||||||
|
|||||||
@ -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>
|
template<unsigned N>
|
||||||
inline Foam::face::face(const FixedList<label, Size>& lst)
|
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))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -121,8 +121,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Operate on a triangle or tetrahedron
|
//- Operate on a triangle or tetrahedron
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
result operator()(const FixedList<point, Size>& p) const
|
result operator()(const FixedList<point, N>& p) const
|
||||||
{
|
{
|
||||||
return result();
|
return result();
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ public:
|
|||||||
Class listOp Declaration
|
Class listOp Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
class listOp
|
class listOp
|
||||||
:
|
:
|
||||||
public uniformOp<zero::null>
|
public uniformOp<zero::null>
|
||||||
@ -321,16 +321,16 @@ public:
|
|||||||
//- Result class
|
//- Result class
|
||||||
class result
|
class result
|
||||||
:
|
:
|
||||||
public DynamicList<FixedList<point, Size>>
|
public DynamicList<FixedList<point, N>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from a single element
|
//- 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
|
//- 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);
|
return result(p);
|
||||||
}
|
}
|
||||||
@ -420,8 +420,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Operate on a triangle or tetrahedron
|
//- Operate on a triangle or tetrahedron
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
result operator()(const FixedList<point, Size>& p) const
|
result operator()(const FixedList<point, N>& p) const
|
||||||
{
|
{
|
||||||
this->data().append(p);
|
this->data().append(p);
|
||||||
return result();
|
return result();
|
||||||
|
|||||||
@ -129,10 +129,10 @@ inline const cut::uniformOp<Type>& tetCutPrism23
|
|||||||
|
|
||||||
|
|
||||||
//- Modify a fixed list for reordering a tri (does nothing)
|
//- 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
|
inline FixedList<Type, 3> triReorder
|
||||||
(
|
(
|
||||||
const FixedList<Type, Size>& x,
|
const FixedList<Type, N>& x,
|
||||||
const FixedList<label, 3>& indices
|
const FixedList<label, 3>& indices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -182,10 +182,10 @@ inline FixedList<Type, 4> triCutQuad
|
|||||||
|
|
||||||
|
|
||||||
//- Modify a fixed list for reordering a tet (does nothing)
|
//- 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
|
inline FixedList<Type, 4> tetReorder
|
||||||
(
|
(
|
||||||
const FixedList<Type, Size>& x,
|
const FixedList<Type, N>& x,
|
||||||
const FixedList<label, 4>& indices
|
const FixedList<label, 4>& indices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -176,11 +176,11 @@ public:
|
|||||||
//- Construct as subset of points
|
//- Construct as subset of points
|
||||||
// The indices could be from edge/triFace etc.
|
// The indices could be from edge/triFace etc.
|
||||||
// Local processor domain only (no reduce as in boundBox)
|
// Local processor domain only (no reduce as in boundBox)
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
treeBoundBox
|
treeBoundBox
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -28,11 +28,11 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<unsigned Size>
|
template<unsigned N>
|
||||||
Foam::treeBoundBox::treeBoundBox
|
Foam::treeBoundBox::treeBoundBox
|
||||||
(
|
(
|
||||||
const UList<point>& points,
|
const UList<point>& points,
|
||||||
const FixedList<label, Size>& indices
|
const FixedList<label, N>& indices
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
boundBox(points, indices, false)
|
boundBox(points, indices, false)
|
||||||
|
|||||||
@ -120,11 +120,11 @@ namespace vtk
|
|||||||
|
|
||||||
//- Write a list of values.
|
//- Write a list of values.
|
||||||
// The output does not include the payload size.
|
// The output does not include the payload size.
|
||||||
template<class Type, unsigned Size>
|
template<class Type, unsigned N>
|
||||||
void writeList
|
void writeList
|
||||||
(
|
(
|
||||||
vtk::formatter& fmt,
|
vtk::formatter& fmt,
|
||||||
const FixedList<Type, Size>& values
|
const FixedList<Type, N>& values
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -57,11 +57,11 @@ void Foam::vtk::writeList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, unsigned Size>
|
template<class Type, unsigned N>
|
||||||
void Foam::vtk::writeList
|
void Foam::vtk::writeList
|
||||||
(
|
(
|
||||||
vtk::formatter& fmt,
|
vtk::formatter& fmt,
|
||||||
const FixedList<Type, Size>& values
|
const FixedList<Type, N>& values
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (const Type& val : values)
|
for (const Type& val : values)
|
||||||
|
|||||||
Reference in New Issue
Block a user