Often, it is more efficient to use a sorted std::vector
instead of a std::set
. Does anyone know a library class sorted_vector
, which basically has a similar interface to std::set
, but inserts elements into the sorted vector (so that there are no duplicates), uses binary search to find
elements, etc.?
I know it's not hard to write, but probably better not to waste time and use an existing implementation anyway.
Update: The reason to use a sorted vector instead of a set is: If you have hundreds of thousands of little sets that contain only 10 or so members each, it is more memory-efficient to just use sorted vectors instead.