Notice
                              
                            
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                        
                    | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 
| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 
| 19 | 20 | 21 | 22 | 23 | 24 | 25 | 
| 26 | 27 | 28 | 29 | 30 | 31 | 
                            Tags
                            
                        
                          
                          - priority_queue
- Algorithm
- 운영체제
- 자료구조
- C언어
- directx
- 아두이노
- list
- WinAPI
- arduino compiler
- 아두이노 소스
- 시스템프로그래밍
- set
- 라인트레이서
- stl
- 수광 소자
- Array
- c++
- Deque
- Stack
- html
- queue
- map
- Visual Micro
- 아두이노 컴파일러
- Arduino
- 통계학
- 컴퓨터 그래픽스
- vector
- LineTracer
                            Archives
                            
                        
                          
                          - Today
- Total
Kim's Programming
Algorithm - all_of() 본문
원형)
| 1 2 | template <class InputIterator, class UnaryPredicate>   bool all_of (InputIterator first, InputIterator last, UnaryPredicate pred); | cs | 
의미)
[Iterator first, Iterator last)사이에 있는 모든 원소들이 pred에 의해서 true를 리턴하면 true를 리턴하고 그 외엔 false를 리턴합니다.
소스)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include<iostream> #include<algorithm> #include<vector> void Print(const std::vector<int>& target) {     for (std::vector<int>::const_iterator iterPos = target.begin(); iterPos != target.cend(); iterPos++)         std::cout << *iterPos << ' ';     std::cout << std::endl; } bool isEven(int val) {     return val % 2 == 0; } void main() {     std::vector<int> vector = { 2,4,6,8,10,12,14,16 };     if(std::all_of(vector.begin(), vector.end(), isEven))         std::cout << "confirm" << std::endl;     else         std::cout << "No" << std::endl; } | cs | 
리턴값)
모든원소가 pred에 대하여 true를 리턴하면 true를 리턴하고 그외의 경우와 범위가 비어있는 경우는 false를 리턴합니다.
결과)
'STL - Algorithm > Algorithm - Non-Modifying' 카테고리의 다른 글
| Algorithm - none_of() (0) | 2017.07.13 | 
|---|---|
| Algorithm - any_if() (0) | 2017.07.13 | 
| Algorithm - search_n() (0) | 2016.02.11 | 
| Algorithm - search() (0) | 2016.02.11 | 
| Algorithm - is_permutation() (0) | 2016.02.07 |