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? 回答1: The efficient way of inserting