3 ms·
Some stuff I can think of: - Hashing can be slower than comparison (or vice-versa), depending on the input. (e.g., imagine if your keys are multi-gigabyte file
by dataflow 4y ago
Some stuff I can think of:
- Hashing can be slower than comparison (or vice-versa), depending on the input. (e.g., imagine if your keys are multi-gigabyte files - hashing them would require reading all of their contents, whereas comparing might only need to read the first few bytes.)
- Ordered maps guarantee good worst-case performance. Unordered maps only guarantee average case. Usually you don't need to care, but with adversarial input you might.
- Ordered maps can guarantee low latency (well, to the extent your allocator can). Unordered maps can't - they suddenly block your program until the whole table is rehashed. Again, usually you don't need to care, but in some situations you might.
- Ordered maps have stable iterators; unordered maps "only" have stable pointers.
- Ordered maps have a guaranteed iteration order that depends solely on their contents; unordered maps don't.
- Any time the ordering itself is useful (see sibling comment)
- ofalkaed 4y agoThat was very helpful, my initial mistake was I forgot about the data and only looked at what was being done too it, but I also neglected how we access that data. My background in analog electronics has made this one of the more difficult things in programming for me, I am used to my data as a stream not as something stored.