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
- Stack
- 아두이노 컴파일러
- WinAPI
- C언어
- Array
- 자료구조
- 라인트레이서
- list
- Deque
- priority_queue
- map
- html
- 운영체제
- arduino compiler
- 아두이노 소스
- set
- 수광 소자
- 아두이노
- stl
- c++
- vector
- directx
- 시스템프로그래밍
- 통계학
- 컴퓨터 그래픽스
- Arduino
- Visual Micro
- LineTracer
- Algorithm
- queue
Archives
- Today
- Total
Kim's Programming
Algorithm - partition_point() 본문
원형)
1 2 3 | template <class ForwardIterator, class UnaryPredicate> ForwardIterator partition_point (ForwardIterator first, ForwardIterator last, UnaryPredicate pred); | cs |
의미)
[Iterator first, Iterator last)사이의 분할된 범위에서 분할 지점을 가리키는 pred함수로 true를 리턴하지 않는 첫 위치를 가리키는 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 30 31 32 | #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 = { 1,2,3,4,5,6,7,8,9 }; std::vector<int>::iterator iter, iterPoint; Print(vector); iter = std::partition(vector.begin(), vector.end(), isEven); Print(vector); iterPoint = std::partition_point(vector.begin(), vector.end(), isEven); if (iterPoint == iter) std::cout << "Same Point" << std::endl; else std::cout << "not Point" << std::endl; } | cs |
리턴값)
pred로 true가 아닌 값을 가리키는 있으면 그 값을 가리키는 Iterator를 리턴하고 true를 리턴하지 않는 값이 없으면 Iterator last를 리턴합니다.
결과)
'STL - Algorithm > Algorithm - Partitions' 카테고리의 다른 글
Algorithm - partition_copy() (0) | 2017.07.11 |
---|---|
Algorithm - stable_partition() (0) | 2017.07.11 |
Algorithm - is_partitioned() (0) | 2017.07.10 |
Algorithm - partition() (0) | 2017.07.10 |