How do I implement the std::unordered_map::insert_or_assign method?
Document: https://en.cppreference.com/w/cpp/container/unordered_map/insert_or_assign
Parameters:
k - the key used both to look up and to insert if not found
hint - iterator to the position before which the new element will be inserted
obj - the value to insert or assign
I am confused as to what hint is suppose to be?
I create a came_from unordered map with Coord classes. (I believe the Coord class is irrelevant here, but if you find necessary, comment, then I will show code). What is the hint parameter suppose to be in this situation?
unordered_map<Coord, Coord>& came_from;
Coord start = Coord(0,0);
Coord goal = Coord(1,1);
came_from.insert_or_assign(start, "What is suppose to be here", goal);
Aucun commentaire:
Enregistrer un commentaire