vector的erase(unique)
时间: 2023-10-21 11:59:01 浏览: 155
Vector常用操作的工程文件
vector的erase(unique)操作是用来删除vector中的重复元素的。首先,通过调用unique函数,将重复的元素都移到vector的末尾,并返回一个指向第一个重复元素的迭代器。然后,通过调用erase函数,擦除从返回的迭代器指向的位置开始的所有元素,直到vector的末尾。这样就实现了删除vector中的重复元素的操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [C++ 之vector元素去重unique()](https://blog.csdn.net/zhangruotong/article/details/127705875)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [STL之vector去重三步曲(利用unique函数)](https://blog.csdn.net/hyl1181/article/details/108983656)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文