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

  • 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)).

主站蜘蛛池模板: 灵山县| 吴江市| 环江| 酒泉市| 油尖旺区| 秦皇岛市| 抚顺县| 四子王旗| 玉环县| 白水县| 丰宁| 崇信县| 白玉县| 海伦市| 高阳县| 建水县| 汤原县| 周至县| 莱西市| 句容市| 玉溪市| 襄汾县| 揭西县| 阿图什市| 长丰县| 林州市| 洪湖市| 中方县| 江都市| 本溪市| 阜城县| 卢龙县| 若羌县| 武隆县| 沈丘县| 吉安市| 宜阳县| 乾安县| 闵行区| 绥滨县| 二连浩特市|