Skip to content

Commit

Permalink
✨ added is_sorted range method
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarrr committed Dec 8, 2024
1 parent 6080361 commit 9ecacb8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ashura/std/range.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ constexpr void indirect_stable_sort(Span<I> indices, Cmp && cmp = {})
stable_sort(indices, [&](I a, I b) { return cmp(a, b); });
}

template <typename T, typename Cmp = Less>
constexpr bool is_sorted(Span<T> indices, Cmp && cmp = {})
{
return std::is_sorted(indices.pbegin(), indices.pend(),
static_cast<Cmp &&>(cmp));
}

template <typename T, typename Predicate>
constexpr Tuple<Span<T>, Span<T>> partition(Span<T> range,
Predicate && predicate)
Expand Down Expand Up @@ -919,7 +926,4 @@ constexpr WindowRange<T> window(Span<T> span, usize window_size)
return window<T>(span, window_size, window_size);
}

// [ ] is_sorted()
// [ ] radix_sort()

} // namespace ash

0 comments on commit 9ecacb8

Please sign in to comment.