5 ms·
I've always thought b-trees should be the starting "default" for everything, because their speed is far more consistent, you get extra features, and you don't h
by crazygringo 7y ago
I've always thought b-trees should be the starting "default" for everything, because their speed is far more consistent, you get extra features, and you don't have to make decisions in advance about allocating extra memory or worry whether the keys aren't well-distributed enough that you'll get horrible collisions. And how often do the extra few lookups for a tree materially affect the speed of your software?
Hash tables to me aren't a go-to -- they're an optimization I reach for only when I have a real performance reason where I have to use them, and my data is highly predictable so I have confidence how to set them up. But honestly, that just doesn't happen that often. I swear, I think I've used Bloom filters more often than hash tables in my life.
- dajohnson89 7y agoof the data structures you mentioned, which are easier to work with? to implement? I code in Java and I usually use hashmaps as a go to. they're simple and fast ways to store relationships between data.
- garmaine 7y agostd::map in C++ is way easier to work with than std::unordered_map (which didn't even exist until C++11).
- yuushi 7y agoDefine "way easier". The interface, at least for day to day operations, is basically identical.
- garmaine 7y agoSupports more features like ordered traversal, generally faster in most cases (yup!), consistent api cost, doesn’t invalidate iterators on certain operations like moving between maps. That’s just off the top of my head.
- garmaine 7y agoI suspect the author of this language and/or his audience has done most of their work in dynamic languages where "associative lookup data structure" means a hash table.