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

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

主站蜘蛛池模板: 洛宁县| 保定市| 同德县| 德安县| 武冈市| 延长县| 内乡县| 江安县| 遂溪县| 夏邑县| 邹平县| 来安县| 准格尔旗| 永和县| 玉溪市| 永福县| 新野县| 嘉善县| 锡林浩特市| 寻乌县| 巩留县| 沙雅县| 资阳市| 庆元县| 北京市| 读书| 綦江县| 德清县| 新和县| 延庆县| 随州市| 嘉黎县| 忻城县| 曲阳县| 上虞市| 绥宁县| 永兴县| 东莞市| 谷城县| 芦山县| 梁平县|