From: Geoffrey H. <ge...@ge...> - 2006-05-25 20:57:48
|
On May 25, 2006, at 10:53 AM, Noel O'Boyle wrote: > I've been reading up on C++, and so can finally make some sense of the > code. What does mol.ReserveAtoms(natom) do though? The API is > silent on > this matter, and the inline code is slightly obaque. Ah. I'll make a note to update the docs on that. In C++, the vector type is a re-sizable array. That means if you start adding objects, it resizes when needed, right? When it resizes, and how much space it adds is an implementation issue. But if you're adding 1,000 atoms at once, chances are good that the vector will resize a few times -- copying data, allocating more memory, etc. If you know ahead of time that you're going to be adding 1,000 atoms, you can improve performance and memory use by allocating that vector right at the beginning: mol.ReserveAtoms(1000); ... Cheers, -Geoff |