- 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();
推薦閱讀
- ASP.NET MVC4框架揭秘
- Building a Home Security System with Raspberry Pi
- Rust編程從入門到實戰
- FreeSWITCH 1.6 Cookbook
- Java Web程序設計
- Securing WebLogic Server 12c
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- C#實踐教程(第2版)
- SQL 經典實例
- Mastering Akka
- HTML5權威指南
- 新印象:解構UI界面設計
- Spring 5 Design Patterns
- Android移動應用開發項目教程
- Android熱門應用開發詳解