mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add constructor/assignment from UIndirectList<label> to PackedList
- more consistent with PackedBoolList
This commit is contained in:
@ -545,6 +545,21 @@ Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
Foam::PackedList<nBits>&
|
||||
Foam::PackedList<nBits>::operator=(const UIndirectList<label>& lst)
|
||||
{
|
||||
setCapacity(lst.size());
|
||||
size_ = lst.size();
|
||||
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<unsigned nBits>
|
||||
|
||||
@ -102,6 +102,7 @@ SourceFiles
|
||||
#define PackedList_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "UIndirectList.H"
|
||||
#include "StaticAssert.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -228,6 +229,9 @@ public:
|
||||
//- Construct from a list of labels
|
||||
explicit inline PackedList(const UList<label>&);
|
||||
|
||||
//- Construct from an indirect list of labels
|
||||
explicit inline PackedList(const UIndirectList<label>&);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr< PackedList<nBits> > clone() const;
|
||||
|
||||
@ -388,12 +392,15 @@ public:
|
||||
//- Assignment of all entries to the given value. Takes linear time.
|
||||
inline PackedList<nBits>& operator=(const unsigned int val);
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
//- Assignment operator.
|
||||
PackedList<nBits>& operator=(const PackedList<nBits>&);
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
//- Assignment operator.
|
||||
PackedList<nBits>& operator=(const UList<label>&);
|
||||
|
||||
//- Assignment operator.
|
||||
PackedList<nBits>& operator=(const UIndirectList<label>&);
|
||||
|
||||
|
||||
// Iterators and helpers
|
||||
|
||||
|
||||
@ -251,6 +251,20 @@ inline Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const UIndirectList<label>& lst)
|
||||
:
|
||||
PackedListCore(),
|
||||
StorageList(packedLength(lst.size()), 0u),
|
||||
size_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<unsigned nBits>
|
||||
inline Foam::autoPtr<Foam::PackedList<nBits> >
|
||||
Foam::PackedList<nBits>::clone() const
|
||||
|
||||
Reference in New Issue
Block a user