-
December 23rd, 2011, 06:58 PM
#1
[RESOLVED] Extracting Elements from STL maps
I have a giant map and using iterator and lower_bound functions I have been able to narrow down to a range relevant to me.
Now I want to copy the locations from first_iterator to last_iterator to another map or rather create a new map from first_iterator to last_iterator. Is there an automatic way of doing it instead of me writing a for loop?
Thanks guys
-
December 23rd, 2011, 07:45 PM
#2
Re: Extracting Elements from STL maps
Use the insert member function that takes 2 iterators:
Code:
m2.insert(it_lower,it_upper);
where
it_lower is the lower bound iterator
it_upper is the upper bound iterator
m2 is the map you want to insert into
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
|
Click Here to Expand Forum to Full Width
|