C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- std::array
- std::vector
- std::map
- std::unordered_map
- std::priority_queue
- std::span
- std::forward_list
- std::forward_list<T,Allocator>::forward_list
- std::forward_list<T,Allocator>::~forward_list
- std::forward_list<T,Allocator>::operator=
- std::forward_list<T,Allocator>::unique
- std::forward_list<T,Allocator>::reverse
- std::forward_list<T,Allocator>::sort
- std::forward_list çæ¨å¯¼æå¼
- std::forward_list<T,Allocator>::merge
- std::forward_list<T,Allocator>::splice_after
- std::forward_list<T,Allocator>::remove, remove_if
- operator==,!=,<,<=,>,>=,<=>(std::forward_list)
- std::swap(std::forward_list)
- std::erase, std::erase_if (std::forward_list)
- std::forward_list<T,Allocator>::swap
- std::forward_list<T,Allocator>::erase_after
- std::forward_list<T,Allocator>::push_front
- std::forward_list<T,Allocator>::emplace_front
- std::forward_list<T,Allocator>::pop_front
- std::forward_list<T,Allocator>::resize
- std::forward_list<T,Allocator>::empty
- std::forward_list<T,Allocator>::max_size
- std::forward_list<T,Allocator>::clear
- std::forward_list<T,Allocator>::insert_after
- std::forward_list<T,Allocator>::emplace_after
- std::forward_list<T,Allocator>::begin, std::forward_list<T,Allocator>::cbegin
- std::forward_list<T,Allocator>::end, std::forward_list<T,Allocator>::cend
- std::forward_list<T,Allocator>::assign
- std::forward_list<T,Allocator>::get_allocator
- std::forward_list<T,Allocator>::front
- std::forward_list<T,Allocator>::before_begin, cbefore_begin
- std::deque
- std::list
- std::set
- std::multiset
- std::multimap
- std::unordered_set
- std::unordered_multiset
- std::unordered_multimap
- std::stack
- std::queue
- std::vector<bool>
- ç»ç¹ææ (C++17)
- 注é
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >容å¨åº >std::forward_list > std::forward_list<T,Allocator>::unique
std::forward_list<T,Allocator>::unique
| (1) | ||
| void unique(); |
(C++11 èµ·) (C++20 å) |
|
| size_type unique(); |
(C++20 èµ·) | |
| (2) | ||
| template< class BinaryPredicate > void unique( BinaryPredicate p ); |
(C++11 èµ·) (C++20 å) |
|
| template< class BinaryPredicate > size_type unique( BinaryPredicate p ); |
(C++20 èµ·) | |
ä»å®¹å¨ç§»é¤ææç¸ç»§çéå¤å
ç´ ãåªçä¸ç¸çå
ç´ ç»ä¸ç第ä¸ä¸ªå
ç´ ã第ä¸çæ¬ç¨ operator== æ¯è¾å
ç´ ï¼ç¬¬äºçæ¬ç¨äºå
è°è¯ p æ¯è¾å
ç´
åæ°
| p | - | è¥å
ç´ åºè¢«å½åç¸çåè¿å âtrue çäºå
è°è¯ã è°è¯å½æ°çç¾ååºçä»·äºå¦ä¸ï¼  bool pred(const Type1 &a, const Type2 &b); è½ç¶ç¾åä¸å¿
æ const & ï¼å½æ°ä¹ä¸è½ä¿®æ¹ä¼ éç»å®ç对象ï¼èä¸å¿
é¡»æ¥åï¼å¯ä¸º const çï¼ç±»å |
è¿åå¼
|
ï¼æ ï¼ |
(C++20 å) |
|
ç§»é¤çå ç´ æ°ã |
(C++20 èµ·) |
å¤æåº¦
ä¸å®¹å¨å¤§å°æçº¿æ§
示ä¾
#include <iostream> #include <forward_list> Â int main() { std::forward_list<int> x = {1, 2, 2, 3, 3, 2, 1, 1, 2}; Â std::cout << "contents before:"; for (auto val : x) std::cout << ' ' << val; std::cout << '\n'; Â x.unique(); std::cout << "contents after unique():"; for (auto val : x) std::cout << ' ' << val; std::cout << '\n'; Â return 0; }
è¾åºï¼
contents before: 1 2 2 3 3 2 1 1 2 contents after unique(): 1 2 3 2 1 2
åé
| ç§»é¤èå´å
çè¿ç»éå¤å
ç´ (彿°æ¨¡æ¿) |