|
From: Rory W. <ror...@ea...> - 2007-07-04 16:03:13
|
I'm afraid I can't say. Perhaps someone else on the list might be able to tell us. For what it's worth I've used both methods and I didn't notice any great difference between the two in terms of execution. Rory. Lloyd wrote: > Thank you Rory, But I would like to know which one would be better (in > execution) > > as you said > >> myvector.resize(10); >> for(int i=0;i<10;i++) >> myvector[i] = 0; >> > > or > > myvector.clear() > for(int i=0;i<10;i++) > myvector.push_back(0); > > Thanks, > Lloyd > > > On Wed, 2007-07-04 at 16:43 +0100, Rory Walsh wrote: >> You can use the resize() like this: >> >> myvector.resize(10); >> for(int i=0;i<10;i++) >> myvector[i] = 0; >> >> More details on vectors can be found here: >> http://www.cppreference.com/cppvector/index.html >> >> regards, >> Rory. >> >> Lloyd wrote: >>> Hi, >>> How can I resize a vector (in STL) and initialize "all" the nodes with >>> a particular value? >>> >>> Thanks and regards, >>> Lloyd >>> >>> > > > > ______________________________________ > Scanned and protected by Email scanner > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |