Handling maps the right way
-
I´ve been using this to insert objects into a map till now:
typedef map<int, edge *> emap; emap::iterator itr = temp_M.begin(); itr = temp_M.find(value); if(itr==temp_M.end()){ temp_M[value] = temp_e;
Is there a shorter way?
I dont know how to use map.insert() yet.
I just know that this doesnt work:mainW->myLogic->aT.insert(mainW->myLogic->aT.size(),temp_v); mainW->myLogic->T.insert(mainW->myLogic->T.size(),temp_v);
with Error:
C:\Users\Nutzer\Documents\BlossomShrinkingVisual\functionloader.cpp:244: Error: no matching function for call to 'std::map<int, vertex*>::insert(int&, vertex*&)' temp_set.insert(container_counter,temp_v); ^
Sry I am new to C++
-
Hi,
The correct function signature for std::map is:
pair<iterator,bool> insert (const value_type& val);
or
iterator insert (iterator position, const value_type& val);
. Note that position is an iterator used as hint.More information here http://www.cplusplus.com/reference/map/map/insert/.
What are you trying to do?
Greetings,
t3685
-
i am coding a visual app for the blossom algorithm for non-bipartite weighted graphs as a bachelor thesis :)