It is possible to change the comparison method of a std::map after it has been created and initialized? Or maybe only after it has been created??
I want to alter somehow the behavior of a class that contains a map that I cannot change the definition. I want to change it's comparison behavior maybe by passing another map.
To update an existing value in the map, first we will find the value with the given key using map::find() function. If the key exists, then will update it with new value.
insert() doesn't overwrite.
By default, a Map in C++ is sorted in increasing order based on its key.
C++ hash map and hash set which preserves the order of insertion. The ordered-map library provides a hash map and a hash set which preserve the order of insertion in a way similar to Python's OrderedDict. When iterating over the map, the values will be returned in the same order as they were inserted.
Maybe it is possible, this is untested:
Have tested, and it is possible to do the above, however changing the comparison function if there are items in the tree can be disastrous...
Anyway - it all sounds too fishy....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With