- 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();
推薦閱讀
- The Supervised Learning Workshop
- Learning Docker
- Instant Zepto.js
- 青少年美育趣味課堂:XMind思維導圖制作
- Oracle數據庫從入門到運維實戰
- 信息安全技術
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- 正則表達式經典實例(第2版)
- Python漫游數學王國:高等數學、線性代數、數理統計及運籌學
- C語言程序設計
- Elasticsearch for Hadoop
- C++20高級編程
- Django Design Patterns and Best Practices
- Mobile Forensics:Advanced Investigative Strategies
- Python應用與實戰