- 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)).
推薦閱讀
- 小程序實戰視頻課:微信小程序開發全案精講
- 前端跨界開發指南:JavaScript工具庫原理解析與實戰
- 深入淺出Windows API程序設計:編程基礎篇
- C#程序設計教程
- Learning Linux Binary Analysis
- C語言程序設計
- Building an RPG with Unity 2018
- PySpark Cookbook
- Android玩家必備
- Visual Foxpro 9.0數據庫程序設計教程
- LabVIEW虛擬儀器入門與測控應用100例
- Scala編程(第5版)
- Hacking Android
- 你真的會寫代碼嗎
- Instant Pygame for Python Game Development How-to