Hacker News new | ask | show | jobs
by lurquer 226 days ago
In C++, I’ve noticed that ChatGPT is fixated on unordered_maps. No matter the situation, when I ask what container would be wise to use, it’s always inordered_maps. Even when you tell it the container will have at most a few hundred elements (a size that would allow you to iterate their a vector to find what your are looking for before the unordered_map even has its morning coffee) it pushes the map… with enough prodding, it will eventually concede that a vector pretty much beats everything for small .size()’s.
2 comments

> (a size that would allow you to iterate their a vector to find what your are looking for before the unordered_map even has its morning coffee)

I don't know about this, whenever I've benchmarked it on my use cases, unordered_map started to become faster than vector at well below 100 elements

I agree with chatgpt here
isn't std::unordered_map famously slow, and you really want the hashmap from abseil, or boost, or folly, or [...]