ranges::prev_permutation
ranges::prev_permutation (이전 순열 — ranges)
범위를 사전순으로 이전 순열로 재배열하는 ranges 버전 알고리즘이에요. <algorithm> 헤더에 있어요.
출처: cppreference
본문
std::ranges::prev_permutation은 범위를 사전순으로 이전 순열로 바꿔요.
namespace std::ranges {
template< std::bidirectional_iterator I, std::sentinel_for<I> S,
class Comp = ranges::less, class Proj = std::identity >
requires std::sortable<I, Comp, Proj>
constexpr prev_permutation_result<I>
prev_permutation( I first, S last, Comp comp = {}, Proj proj = {} );
}
- 반환 타입
prev_permutation_result{in, found}. found는 이전 순열로 변환되면true. 이미 첫(가장 작은) 순열이면 마지막 순열로 되돌리고false.
next_permutation의 반대 연산이에요. 역순으로 순열을 탐색하는 ranges 버전이에요.