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

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

主站蜘蛛池模板: 黄陵县| 潮州市| 天台县| 高青县| 天峨县| 黔西| 虹口区| 仲巴县| 喀喇沁旗| 祥云县| 福州市| 保山市| 宿迁市| 崇州市| 观塘区| 东宁县| 嫩江县| 封丘县| 措美县| 噶尔县| 开阳县| 乐都县| 曲阳县| 涿州市| 陵川县| 桦甸市| 五台县| 旬邑县| 修水县| 绥化市| 蒲城县| 德兴市| 富裕县| 广河县| 迁安市| 南郑县| 鱼台县| 昌平区| 时尚| 茶陵县| 晋城|