visual c++ - make insert one by one in order C++ -


I have an empty array list and I want to insert this array one by one in my array data structure. When I create my joined function then it is inserted in the order

The test is arr (9,10,7,8,5,6,3,4,1,2};
insert after listing {1,3,5,7,9,10,8,6,4,2}
enter my entry function block

  zero (Value_type D) {if (data. Size () == 0) {data.push_back (d); } And if (data. Size ()> gt; 0) {// get data / std :: list & lt; Value_type & gt; :: iterator iter = data.begin (); (AutoItre = data.bizin (); ITAR! = For data.and (); ++Iter) (if (d> gt; * etter) {data.push_back (d); breakdown;} and if (d & Lt; = * iter) {data.insert (iter, d); break;}}}}}  

It will appear that you are trying to include an inclusion like the standard library you have covered:

Find out that the new element should go to O (Logan) - Upper_bound is a binary search:

  var pos = std :: upper_bound (data.bizin), data.ed (), d);  

Insert element there:

  data.insert (pos, d);  

Or as a liner for your entire function ...

  data.insert (std :: upper_bound (data.begin (), data .end (), d), d);  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -