-
assigning multiple elements to a vector?
Does anyone know whether there is a way to assign multiple copies of an element to the end of an STL vector? I mean succintly ... of course you can use a for loop and the push_back function ... is there a way to assign multiple copies of a element to the end of a pre-existing vector though? I thought the assign function did that but it over writes what is already in it. Any help appreciated as usual ...
(btw: does anyone post replies on this forum other than Danny? I would but I'm afraid I don't know enough to be helpful w/ most of the posts I read)
-
 Originally Posted by bpw1621
Does anyone know whether there is a way to assign multiple copies of an element to the end of an STL vector? I mean succintly ... of course you can use a for loop and the push_back function ... is there a way to assign multiple copies of a element to the end of a pre-existing vector though? I thought the assign function did that but it over writes what is already in it. Any help appreciated as usual ...
You probably mean assign()? Look at this member function. It has severa overloaded versions but the bottom line is this: it assigns to a sequence of elements in a vector (or a similar container) at once. Another technique is using stream iterators but it's not as intuitive as calling assign(). See:
http://www.devx.com/getHelpOn/10MinuteSolution/20410
 Originally Posted by bpw1621
(btw: does anyone post replies on this forum other than Danny? I would but I'm afraid I don't know enough to be helpful w/ most of the posts I read)
Of course there are other people replying; it's just that I have to have the last word;) Seriously, there are many regular members here who post replies every day.
Danny Kalev
-
I dunno I take a crack at helping when I can but am no guru. I just hope I help more often than not...
Similar Threads
-
Replies: 2
Last Post: 07-28-2005, 05:43 AM
-
Replies: 6
Last Post: 07-19-2005, 04:24 PM
-
Replies: 3
Last Post: 02-14-2005, 06:48 AM
-
Replies: 2
Last Post: 02-28-2002, 04:07 PM
-
Replies: 1
Last Post: 11-05-2000, 08:34 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks