Originally Posted by
Daved
The sorted vector idea works best if you add all your elements at the start, then sort them (and make them unique if necessary) before using them. If the data must be unique, it works best if you don't have a lot of duplicates.
If you do have a lot of duplicates, then adding everything to the vector first could waste a lot of space (although you might be able to make the data unique in stages to reduce that waste).
If you don't insert all the elements at the beginning, and instead do it as you go (meaning you insert some elements, then use the vector, then insert some more, then use the vector, etc), then a vector is a bad idea because you would either have to insert into the middle (which is costly) or sort the container and make it unique each time you add something. Both options might be slower than using the set and then at the end copying to a vector, but it sounds like this might not be a problem for you if you're just filling the container before sending it.