Iros
 
Loading...
Searching...
No Matches
partition.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace di::container {
6namespace detail {
8 template<concepts::InputIterator It, concepts::SentinelFor<It> Sent, typename Proj = function::Identity,
9 concepts::IndirectUnaryPredicate<meta::Projected<It, Proj>> Pred>
11 constexpr auto operator()(It first, Sent last, Pred pred, Proj proj = {}) const -> View<It> {
12 // Find the first element that does not belong to the left of the partition point.
13 auto fast = container::find_if_not(util::move(first), last, util::ref(pred), util::ref(proj));
14 if (fast == last) {
15 return { fast, fast };
16 }
17
18 // Swap any element which is out of place back into place.
19 auto slow = fast++;
20 for (; fast != last; ++fast) {
21 if (function::invoke(pred, function::invoke(proj, *fast))) {
22 container::iterator_swap(slow++, fast);
23 }
24 }
25 return { util::move(slow), util::move(fast) };
26 }
27
28 template<concepts::InputContainer Con, typename Proj = function::Identity,
29 concepts::IndirectUnaryPredicate<meta::Projected<meta::ContainerIterator<Con>, Proj>> Pred>
30 requires(concepts::Permutable<meta::ContainerIterator<Con>>)
31 constexpr auto operator()(Con&& container, Pred pred, Proj proj = {}) const -> meta::BorrowedView<Con> {
33 }
34 };
35}
36
37constexpr inline auto partition = detail::PartitionFunction {};
38}
39
40namespace di {
42}
Definition view.h:35
Definition permutable.h:9
Definition sequence.h:13
Definition sequence.h:12
constexpr auto partition
Definition partition.h:37
constexpr auto iterator_swap
Definition iterator_swap.h:49
constexpr auto find_if_not
Definition find_if_not.h:31
constexpr auto end
Definition end.h:47
constexpr auto begin
Definition begin.h:44
constexpr auto invoke
Definition invoke.h:100
Conditional< concepts::BorrowedContainer< Con >, container::View< ContainerIterator< Con > >, container::Dangling > BorrowedView
Definition borrowed_view.h:12
constexpr auto ref
Definition reference_wrapper.h:98
Definition zstring_parser.h:9
constexpr auto proj
Definition proj.h:59