Why You Should Never Use a set

std::unordered_set looks like O(1), but in hot C++ loops the memory access pattern can dominate. Here is a duplicate-filtering benchmark with dense ids, sparse ids, Boost dynamic_bitset, sort+unique, and the case where unordered_set wins.