How to efficiently insert a range of consecutive integers into a std::set?
In C++, I have a std::set that I would like to insert a range of consecutive integers. How can I do this efficiently, hopefully in O(n) time where n is the length of the range? I'm thinking I'd use the inputIterator version of std::insert, but am unclear on how to build the input iterator. std::set<int> mySet; // Insert [34 - 75): mySet.insert(inputIteratorTo34, inputIteratorTo75); How can I create the input iterator and will this be O(n) on the range size? The efficient way of inserting already ordered elements into a set is to hint the library as to where the next element will be. For that