官术网_书友最值得收藏!

  • Mastering C++ Programming
  • Jeganathan Swaminathan
  • 109字
  • 2021-07-02 18:28:50

Code walkthrough

The following line declares a vector and initializes the vector with five elements:

vector<int> v = { 1, 5, 2, 4, 3 };

However, a vector also allows appending values to the end of the vector by using the vector::push_back<data_type>( value ) API. The sort() algorithm takes two random access iterators that represent a range of data that must be sorted. As the vector internally uses a built-in C/C++ array, just like the STL array container, a vector also supports random access iterators; hence the sort() function is a highly efficient algorithm whose runtime complexity is logarithmic, that is, O(N log2 (N)).

主站蜘蛛池模板: 贵阳市| 和政县| 兴隆县| 普格县| 邢台县| 山东省| 岳阳县| 若羌县| 三原县| 碌曲县| 耒阳市| 张家港市| 安溪县| 化隆| 靖边县| 长顺县| 梧州市| 冷水江市| 界首市| 陵川县| 庆城县| 绍兴县| 西丰县| 全州县| 南汇区| 长白| 海丰县| 大荔县| 维西| 海安县| 镇远县| 汽车| 德州市| 左贡县| 曲麻莱县| 高碑店市| 闽清县| 若羌县| 深水埗区| 二连浩特市| 重庆市|