This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Containers: assignment, construction from


On Fri, 18 Feb 2000, Anjul wrote:
> Is there a better list to post this question to?

Use one of the C++ newsgroups, but have a look at the documentation at
http://www.sgi.com/Technology/STL/ first, there's lot of interesting
stuff.

> The reason I prefer this is to avoid needless construction of blank
> elements in the first case. Yes, I could create a vector of size 0 and
> use a back_inserter as an argument to the copy command, but then, I
> may run into repeated "reallocs" (extensions), some of which may
> necessiate copying the entire vector.

You want to use vector<>::reserve().

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]