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 |
Tags
- 통계학
- list
- Algorithm
- 운영체제
- set
- html
- WinAPI
- 아두이노 소스
- Array
- directx
- arduino compiler
- 수광 소자
- Stack
- 자료구조
- 아두이노
- map
- 컴퓨터 그래픽스
- Arduino
- 라인트레이서
- priority_queue
- 아두이노 컴파일러
- Visual Micro
- 시스템프로그래밍
- stl
- queue
- Deque
- c++
- C언어
- vector
- LineTracer
Archives
- Today
- Total
Kim's Programming
Algorithm - any_if() 본문
원형)
1 2 | template <class InputIterator, class UnaryPredicate> bool any_of (InputIterator first, InputIterator last, UnaryPredicate pred); | cs |
의미)
[Iterator first, Iterator last)사이의 데이터 중에서 어느 하나의 원소라도 pred에 대하여 true를 리턴하면 true를 리턴합니다.
소스)
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::any_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 - for_each() (0) | 2017.07.13 |
---|---|
Algorithm - none_of() (0) | 2017.07.13 |
Algorithm - all_of() (0) | 2017.07.13 |
Algorithm - search_n() (0) | 2016.02.11 |
Algorithm - search() (0) | 2016.02.11 |