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
                            
                        
                          
                          - 컴퓨터 그래픽스
- 아두이노 컴파일러
- stl
- LineTracer
- 운영체제
- Visual Micro
- Arduino
- queue
- 라인트레이서
- 통계학
- directx
- Deque
- Stack
- 아두이노
- c++
- WinAPI
- vector
- priority_queue
- C언어
- Algorithm
- 수광 소자
- 시스템프로그래밍
- map
- set
- html
- arduino compiler
- 아두이노 소스
- list
- Array
- 자료구조
                            Archives
                            
                        
                          
                          - Today
- Total
Kim's Programming
Algorithm - is_sorted_until() 본문
원형)
| 1 2 3 4 5 6 7 8 | //기본형 template <class ForwardIterator>   ForwardIterator is_sorted_until (ForwardIterator first, ForwardIterator last); //사용자 정의형 template <class ForwardIterator, class Compare>   ForwardIterator is_sorted_until (ForwardIterator first, ForwardIterator last,                                    Compare comp); | cs | 
의미)
[Iterator first, ITerator last)사이의 데이터들 중에서 오름차순으로 정렬되지 않은 첫 원소를 리턴합니다.
소스)
| 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.cbegin(); iterPos != target.cend(); iterPos++)         std::cout << *iterPos << " ";     std::cout << std::endl; } void main() {     std::vector<int> vector = { 20,10,5,15 };     std::vector<int>::iterator iter;     Print(vector);     std::is_sorted_until(vector.begin(), vector.end());     Print(vector);     do     {         std::prev_permutation(vector.begin(), vector.end());         std::cout << "Vector:";         Print(vector);         iter = std::is_sorted_until(vector.begin(), vector.end());         std::cout << " (" << (iter - vector.begin()) << " elements sorted)\n";     } while (iter != vector.end());     std::cout << "the range is sorted!\n"; } | cs | 
내용)
[Iterator first, ITerator last)사이의 데이터들 중에서 오름차순으로 정렬되지 않은 첫 원소를 리턴합니다. 범위내에 2개 미만의 원소가 있거나 모든 원소들이 정렬이 되어있으면 Iterator last를 리턴합니다.
결과)
'STL - Algorithm > Algorithm - Sorting' 카테고리의 다른 글
| Algorithm - is_sorted() (0) | 2017.06.30 | 
|---|---|
| Algorithm - partial_sort_copy() (0) | 2017.06.30 | 
| Algorithm - partial_sort() (0) | 2017.06.30 | 
| Algorithm - stable_sort() (0) | 2017.06.30 | 
| Algorithm - sort() (0) | 2017.06.30 |