inserting into a map

Discussion in 'Mac Programming' started by swimlikehell, Oct 27, 2006.

  1. macrumors member

    Joined:
    Aug 31, 2006
    #1
    I m trying to insert into a map set up like <string, uint16> if anyone could let me know what i need to do to put information into this it would be much appreciated. thanks
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    What language are you using? What Frameworks/APIs? POST YOUR CODE
     
  3. macrumors member

    SamMiller0

    Joined:
    Aug 17, 2004
    Location:
    San Jose, CA
    #3
    The easiest method is probably:

    Code:
    typedef std::map<std::string, uint16_t> HashTable;
    HashTable foo;
    foo.insert(HashTable::value_type("hello world", 42));
    
     
  4. macrumors 68040

    iSee

    Joined:
    Oct 25, 2004
    #4
    easiest method:
    Code:
    	std::map<std::string, uint16_t> myMap;
    	myMap["the key"] = 77;
    
    just accessing the map with the square bracket operator will insert a value
     

Share This Page