mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
List - adjusted transfer(DynamicList) and added transfer(SortableList)
This commit is contained in:
@ -100,6 +100,15 @@ int main(int argc, char *argv[])
|
||||
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
|
||||
<< " " << dlB.size() << "/" << dlB.allocSize() << endl;
|
||||
|
||||
// try with a normal list:
|
||||
List<label> lstA;
|
||||
lstA.transfer(dlB);
|
||||
Info<< "Transferred to normal list" << endl;
|
||||
Info<< "<lstA>" << lstA << "</lstA>" << nl << "sizes: "
|
||||
<< " " << lstA.size() << endl;
|
||||
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
|
||||
<< " " << dlB.size() << "/" << dlB.allocSize() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -70,6 +70,13 @@ int main(int argc, char *argv[])
|
||||
Info << "sorted: " << b << endl;
|
||||
Info << "indices: " << b.indices() << endl;
|
||||
|
||||
labelList flatten;
|
||||
flatten.transfer(b);
|
||||
|
||||
Info << "flatten: " << flatten << endl;
|
||||
Info << "sorted: " << b << endl;
|
||||
Info << "indices: " << b.indices() << endl;
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -432,14 +432,20 @@ void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a)
|
||||
{
|
||||
// shrink the allocated space to the number of elements used
|
||||
a.shrink();
|
||||
|
||||
if (this->v_) delete[] this->v_;
|
||||
this->size_ = a.size_;
|
||||
this->v_ = a.v_;
|
||||
|
||||
a.size_ = 0;
|
||||
a.v_ = 0;
|
||||
a.allocSize_ = 0;
|
||||
|
||||
transfer(static_cast<List<T>&>(a));
|
||||
}
|
||||
|
||||
|
||||
// Transfer the contents of the argument SortableList into this List
|
||||
// and anull the argument list
|
||||
template<class T>
|
||||
void Foam::List<T>::transfer(SortableList<T>& a)
|
||||
{
|
||||
// shrink away the sort indices
|
||||
a.shrink();
|
||||
transfer(static_cast<List<T>&>(a));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -63,7 +63,8 @@ template<class T, label Size> class FixedList;
|
||||
template<class T> class PtrList;
|
||||
template<class T> class SLList;
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
class DynamicList;
|
||||
class DynamicList;
|
||||
template<class T> class SortableList;
|
||||
template<class T> class IndirectList;
|
||||
template<class T> class BiIndirectList;
|
||||
|
||||
@ -173,6 +174,10 @@ public:
|
||||
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
||||
|
||||
//- Transfer the contents of the argument List into this List
|
||||
// and annull the argument list.
|
||||
void transfer(SortableList<T>&);
|
||||
|
||||
//- Return subscript-checked element of UList.
|
||||
inline T& newElmt(const label);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user