c++ - STL: Set of natural numbers from A to B -


I want to add natural numbers to ABC in a set. Currently, I am putting each number in A to B, by doing this one-by-one in the set,

  set < Int & gt; S; For (int j = a; j & lt; = b; j ++) s.insert (j);  

but it takes o (n) time (here n = (B - A) +1 ). O (1) time

thanks

n Allocation of memory to hold the number is always at least in O (N), so I think that you are out of luck.


Comments