Commit 96751f7e authored by Mark Olesen's avatar Mark Olesen
Browse files

Applied Mattijs' DynamicList copy constructor patch

parent 7ab7eaa4
......@@ -160,6 +160,19 @@ int main(int argc, char *argv[])
<< " " << lstB.size() << endl;
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
<< " " << 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;
}
......
......@@ -101,7 +101,14 @@ public:
//- Construct given size.
explicit inline DynamicList(const label);
//- Construct copy.
explicit inline DynamicList
(
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
//- Construct from UList. Size set to UList size.
// Also constructs from DynamicList with different sizing parameters.
explicit inline DynamicList(const UList<T>&);
//- 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>
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)
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
......
Supports Markdown
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