John Peterson wrote: > On Thu, Nov 6, 2008 at 4:17 PM, Roy Stogner <[EMAIL PROTECTED]> wrote: >> Does anyone know which STL vector operations exist reduce capacity()? As far >> as I know swap() and reserve() are the only ways to do so, but I'd hate to >> find out that some resize() implementation also "helpfully" reduced capacity >> for you when we don't want it to. > > The only way to *guarantee* capacity reduction is to swap with an > empty vector.
Well, to swap with a smaller vector, anyway. As far as I can tell (looking at Effective STL) even that isn't a guarantee, if you've got some weird implementation which thinks that starting empty vectors off with a non-zero capacity averages out to be more efficient. > There may be some STL implementations which reduce > capacity in other ways, but this would not be efficient in a lot of > cases and I don't know of any which do so. Ah! I looked it up in Stroustrup - "Decreasing the size of a vector doesn't decrease it's capacity" (except if you do it indirectly with the swap trick). That's what I was hoping to hear. --- Roy ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libmesh-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-devel
