Hacker News new | ask | show | jobs
by cesarb 1926 days ago
> People often use set instead of unordered_set (and same for map) despite not needing order. This slows things down.

Aren't unordered_set and unordered_map quite new (IIRC, they came only with C++0x)? For most of C++'s history, if you preferred to use the standard library, what you had was only ordered sets and maps.

4 comments

Depends what’s your definition of “quite new”. That’s over 10 years go now :)
They've been in the language for about a decade now, and before that we had the tr1 hash_map classes that were available in most environments.
C++: the language that's been around for 40 years and is completely new!
Actually, C++ has barely been around at all. It is only with C++20, IIANM, that they key features Bjarne Stroustrup wanted to imbue it with are in place (IIRC; see his "Design & Evolution of C++" book from 1994). Some might even argue that the language C++ _should_ be is not even all here; it's still gradually arriving.
By now, this is no longer "quite new". A recent C++ community survey suggests that under 10% of developers currently use C++98/C++03 the most. Naturally this is not a valid sample of the whole userbase, but it's a good indication.

Also, in 2005 IIANM, Google published their dense and sparse hash map implementations, which were fast-ish and quite usable.

They were in TR1 in 2005, if I am not mistaken.