- 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)).
推薦閱讀
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- Angular UI Development with PrimeNG
- SpringMVC+MyBatis快速開發(fā)與項目實戰(zhàn)
- Machine Learning with R Cookbook(Second Edition)
- JIRA 7 Administration Cookbook(Second Edition)
- OpenCV 3和Qt5計算機視覺應用開發(fā)
- Java程序設計與實踐教程(第2版)
- SSM開發(fā)實戰(zhàn)教程(Spring+Spring MVC+MyBatis)
- Building Machine Learning Systems with Python(Second Edition)
- Building Microservices with .NET Core
- 視窗軟件設計和開發(fā)自動化:可視化D++語言
- 3ds Max 2018從入門到精通
- MATLAB 2020 GUI程序設計從入門到精通
- Java EE 7 Development with WildFly
- Improving your Penetration Testing Skills