- Mastering C++ Programming
- Jeganathan Swaminathan
- 70字
- 2021-07-02 18:28:51
Code walkthrough
The following code declares and initializes the forward_list container with some unique values and some duplicate values:
forward_list<int> l = { 10, 10, 20, 30, 45, 45, 50 };
As the forward_list container doesn't support the size() function, we used the distance() function to find the size of the list:
cout << "\nSize of list with duplicates is " << distance( l.begin(), l.end() ) << endl;
The following forward_list<int>::unique() function removes the duplicate integers and retains only the unique values:
l.unique();
推薦閱讀
- UI圖標創意設計
- The Modern C++ Challenge
- SOA實踐
- Vue.js 2 and Bootstrap 4 Web Development
- PHP+MySQL網站開發項目式教程
- Python算法指南:程序員經典算法分析與實現
- Android移動開發案例教程:基于Android Studio開發環境
- 深度學習原理與PyTorch實戰(第2版)
- Spring 5 Design Patterns
- Modernizing Legacy Applications in PHP
- Visual C++開發寶典
- Java并發實現原理:JDK源碼剖析
- Node.js 6.x Blueprints
- RStudio for R Statistical Computing Cookbook
- 數據結構:Python語言描述