3 ms·
When reading the title I thought that it is about complexity of linear search vs. better alternatives like hash sets/maps, or at least sorted data structures (b
by felixguendling 5y ago
When reading the title I thought that it is about complexity of linear search vs. better alternatives like hash sets/maps, or at least sorted data structures (binary search).
But if having linear complexity is fine, std::find_if/any_of/none_of/all_of/etc. are of course fine and you should prefer the version that's most expressive.
- kragen 5y agoOf course; as Larry Wall said, doing a sequential search over the keys of a hash table is like clubbing someone to death with a loaded Uzi.
- mywittyname 5y agoIt's safer, more reliable, and easier to clean up after?
- Zababa 5y agoI doubt it will be safer and more reliable unless the person doesn't fight back. I do agree for cleanup, especially if the bullets go through.