4 ms·
They are also slow AF because a lookup takes linear time.
by oweiler 2y ago
They are also slow AF because a lookup takes linear time.
- Izkata 2y agoWhich is because they're not hashmaps, they're associative arrays. Article treats them as the same thing, but they're not - that's why the "declare -A" is A and not H - it stands for "associative".
- xena 2y agoAuthor of the article here. As far as I care, if it quacks like a hashmap, it's better to describe it as a hashmap. The fact that it's an associative array under the hood is irrelevant.
- tremon 2y agoIt doesn't; it's just that you probably never heard the quack of a hashmap so you don't know the difference. A hashmap is a very specific structure that uses a hashing algorithm to normalize the key sizes, and then usually constructs a tree-like structure for fast key lookups. Anything that doesn't use such an implementation under the hood should not be called a hashmap, whether you care or not.
- globular-toast 2y agoYou have this the wrong way around. Associative array is the abstraction you are talking about. Hash maps are a specific implementation of that abstraction. You could also define hash map as an abstraction which has the same interface as associative array but with more strict performance characteristics. But either way it's wrong because bash is neither implemented as a hash map nor has the performance characteristics of a hash map. For reference the main implementations of associative array are alists/plists (linear time), balanced binary trees, b-trees (logarithmic time) and hash maps (amortised constant time).
- d_tr 2y agoIt sounds like you don't even know what these words mean.