CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Location
    NY, USA
    Posts
    191

    [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

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

    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
  •  





Click Here to Expand Forum to Full Width

Featured