- 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();
推薦閱讀
- Learning LibGDX Game Development(Second Edition)
- Deploying Node.js
- C語言程序設計教程
- JMeter 性能測試實戰(第2版)
- Responsive Web Design with HTML5 and CSS3
- AIRAndroid應用開發實戰
- Mastering PHP Design Patterns
- Python High Performance Programming
- 區塊鏈技術進階與實戰(第2版)
- Java Web應用開發項目教程
- Java Web開發實例大全(基礎卷) (軟件工程師開發大系)
- Python Machine Learning Cookbook
- C#程序設計基礎入門教程
- Slick2D Game Development
- Java基礎案例教程(第2版)