c++ - How do I change the map container's internal sorting scheme? -
i'm beginner c++ programmer there language constructs don't understand prevents me understanding map's api (for reference, here)
more point, questions:
how change internal sorting scheme of map that, given we're working map::<string, ...>, key values sorted alphabetically?
more map::key_comp, define-and-forget thing once define means 2 elements of same type "unequal (one less other)", sorting done internally , automatically - need insert key/value pairs? or have define equality/ordering , call function explicitly return boolean implement ordered insertion?
here's example of how give sorted map template argument use non-default sort:
std::map<int, int, std::greater<int> > m; taken c++ std::map items in descending order of keys
also, more complex example: how declare custom sort function on std::map declaration?
Comments
Post a Comment