Commit bb32504c authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add constructor/assignment from UIndirectList<label> to PackedList

- more consistent with PackedBoolList
parent 514661e9
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment