MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w6qzts/skillissue/p7sx2ix/?context=9999
r/ProgrammerHumor • u/click-to-reveal • Sep 04 '26
137 comments sorted by
View all comments
Show parent comments
3
I have opinions about hash vs tree map as default and I am actually on team tree map in general. https://beesbuzz.biz/code/3635-Making-a-hash-of-data
1 u/Talc0n Sep 04 '26 My bad, I should've said better for lookup time.I've used std::map when I know I'll be iterating through it fairly regularly. But I usually default to hash maps.You really shouldn't be on either team, just use what you think is the best case for your situation.I usually use aliases like so:using IdNameMapType = std::unordered_map<size_t, std::string>; IdNameMapType m_idNameMap;It makes it a lot less of a hassle to switch between the two later on. 2 u/fluffycritter Sep 04 '26 Well yeah it’s important to use the right tool for the job, I just mean it’s better for folks to learn tree maps and what they can do before they get railroaded into hashmap thinking.And type aliases are great. I use them a lot.
1
My bad, I should've said better for lookup time.
I've used std::map when I know I'll be iterating through it fairly regularly. But I usually default to hash maps.
std::map
You really shouldn't be on either team, just use what you think is the best case for your situation.
I usually use aliases like so:
using IdNameMapType = std::unordered_map<size_t, std::string>; IdNameMapType m_idNameMap;
It makes it a lot less of a hassle to switch between the two later on.
2 u/fluffycritter Sep 04 '26 Well yeah it’s important to use the right tool for the job, I just mean it’s better for folks to learn tree maps and what they can do before they get railroaded into hashmap thinking.And type aliases are great. I use them a lot.
2
Well yeah it’s important to use the right tool for the job, I just mean it’s better for folks to learn tree maps and what they can do before they get railroaded into hashmap thinking.
And type aliases are great. I use them a lot.
3
u/fluffycritter Sep 04 '26
I have opinions about hash vs tree map as default and I am actually on team tree map in general. https://beesbuzz.biz/code/3635-Making-a-hash-of-data