Thread: Map

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    197

    Map

    Code:
    it2=mymap.find(i);
         if(it2!=mymap.end())
         {
    
    }
    isn't this enough to check whether the map contains i...
    It doesn't work for me...
    Am i wrong?
    If yes ,wat shud be the snippet
    Last edited by dpp; 06-25-2009 at 11:46 PM.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    And what is the type of i? Does it implement ordering correctly?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by dpp View Post
    Code:
    it2=mymap.find(i);
         if(it2!=mymap.end())
         {
    
    }
    isn't this enough to check whether the map contains i...
    It doesn't work for me...
    Am i wrong?
    If yes ,wat shud be the snippet
    "It doesn't work". There we have the most useless combination of 3 words in the entire language.
    Consider yourself duely strangled! When you come to, kindly explain what the hell you mean. Start with whether you are getting a compile error or a runtime error.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    That's the correct way to check if an item is in the map. If it's "not working" then either you are mistaken about the item being/not being present, or the type of the object you are storing in the map does not correctly implement a partial ordering.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding a Map to a program
    By Shogun32 in forum C++ Programming
    Replies: 1
    Last Post: 05-04-2009, 09:42 AM
  2. New editor updates
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-05-2005, 03:26 PM
  3. Creating a map engine.
    By suzakugaiden in forum Game Programming
    Replies: 11
    Last Post: 06-21-2005, 05:06 AM
  4. Searching STL Map Inside STL Map Object :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2002, 09:11 AM
  5. my map is showing up 90 degrees turned!
    By frenchfry164 in forum C++ Programming
    Replies: 8
    Last Post: 03-28-2002, 02:32 PM