mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Applied Mattijs' DynamicList copy constructor patch
This commit is contained in:
@ -160,6 +160,19 @@ int main(int argc, char *argv[])
|
|||||||
<< " " << lstB.size() << endl;
|
<< " " << lstB.size() << endl;
|
||||||
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
|
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
|
||||||
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
|
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
|
||||||
|
|
||||||
|
DynamicList<label,10> dlE1(10);
|
||||||
|
DynamicList<label> dlE2(dlE1);
|
||||||
|
|
||||||
|
Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: "
|
||||||
|
<< " " << dlE1.size() << "/" << dlE1.capacity() << endl;
|
||||||
|
Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: "
|
||||||
|
<< " " << dlE2.size() << "/" << dlE2.capacity() << endl;
|
||||||
|
|
||||||
|
dlE2.append(100);
|
||||||
|
Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl;
|
||||||
|
|
||||||
|
Info<< "\nEnd\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,7 +101,14 @@ public:
|
|||||||
//- Construct given size.
|
//- Construct given size.
|
||||||
explicit inline DynamicList(const label);
|
explicit inline DynamicList(const label);
|
||||||
|
|
||||||
|
//- Construct copy.
|
||||||
|
explicit inline DynamicList
|
||||||
|
(
|
||||||
|
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from UList. Size set to UList size.
|
//- Construct from UList. Size set to UList size.
|
||||||
|
// Also constructs from DynamicList with different sizing parameters.
|
||||||
explicit inline DynamicList(const UList<T>&);
|
explicit inline DynamicList(const UList<T>&);
|
||||||
|
|
||||||
//- Construct by transferring the parameter contents
|
//- Construct by transferring the parameter contents
|
||||||
|
|||||||
@ -50,6 +50,17 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||||
|
(
|
||||||
|
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
|
)
|
||||||
|
:
|
||||||
|
List<T>(lst),
|
||||||
|
capacity_(lst.size())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||||
(
|
(
|
||||||
@ -99,7 +110,6 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity
|
|||||||
}
|
}
|
||||||
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||||
|
|
||||||
|
|
||||||
List<T>::setSize(capacity_);
|
List<T>::setSize(capacity_);
|
||||||
List<T>::size(nextFree);
|
List<T>::size(nextFree);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user