News for hackers. Stuff that matters.
Re:Why databases use ordered indexes but programming uses ha... by bnegreve on Tuesday December 10, 2019 @01:48AM (#21750278)
Developers primarily use sorted maps because the sorted map is the default map type in C++, by name. (I would be different if you had map/sorted_map instead).

The real question, is why C++ designers chose to prioritize sorted maps (RBTrees) over unsorted maps (Hash Maps).

I don't think it's a matter of speed though. I think it's because RBTrees are safer to use. Things can go really wrong with a hashmap if you have a poor hashing function (worst case search is O(n) vs. O(log(n)) for a RBTree)

There are no comments on this comment yet.