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 |
Tags
- stl
- 아두이노 컴파일러
- Visual Micro
- Deque
- 통계학
- 자료구조
- c++
- Algorithm
- 아두이노 소스
- queue
- WinAPI
- 운영체제
- 아두이노
- list
- arduino compiler
- LineTracer
- Array
- 라인트레이서
- html
- Stack
- C언어
- 시스템프로그래밍
- map
- vector
- directx
- 컴퓨터 그래픽스
- priority_queue
- set
- Arduino
- 수광 소자
Archives
- Today
- Total
Kim's Programming
Algorithm - find_end() 본문
원형)
1 2 3 4 5 6 7 8 9 10 | //기본형 template <class ForwardIterator1, class ForwardIterator2> ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); //사용자 정의형 template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> ForwardIterator1 find_end (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); | cs |
의미)
ㅇ[Iterator first, Iterator last)사이 범위에서 [Iterator first, Iterator last)사이의 연속된 데이터가 있는지 확인을 하고 연속된 데이터의 가장 앞을 가리키는 Iterator를 리턴합니다.
소스)
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 | #include<iostream> #include<algorithm> #include<vector> bool findEnd(int i, int j) { return i == j; } void main() { std::vector<int> vector = { 0,2,4,6,8,10,2,4,6,8 }; std::vector<int>::iterator iter; std::vector<int> vectorCopy = { 2,4,10 }; iter = std::find_end(vector.begin(), vector.end(), vectorCopy.begin(), vectorCopy.end()); if (iter != vector.end()) std::cout << "-> " << *iter << std::endl; else std::cout << "No data" << std::endl; std::vector<int> vector2 = { 10,2,4 }; iter = std::find_end(vector.begin(), vector.end(), vector2.begin(), vector2.end(), findEnd); if (iter != vector.end()) std::cout << "-> " << *iter << std::endl; else std::cout << "No data" << std::endl; } | cs |
리턴값)
[Iterator first, Iterator last)사이가 비어있으면 Iterator last1를 리턴합니다.
결과)
'STL - Algorithm > Algorithm - Non-Modifying' 카테고리의 다른 글
| Algorithm - find_if_not() (0) | 2017.07.13 |
|---|---|
| Algorithm - find_if() (0) | 2017.07.13 |
| Algorithm - find() (0) | 2017.07.13 |
| Algorithm - for_each() (0) | 2017.07.13 |
| Algorithm - none_of() (0) | 2017.07.13 |