Ref T386, partial sort

This commit is contained in:
Klaus Basan
2018-10-04 16:53:00 +02:00
parent d556383090
commit 7e47349b30

View File

@@ -462,7 +462,7 @@ namespace BlackMisc
//! In-place move the smallest n elements to the beginning and sort them. //! In-place move the smallest n elements to the beginning and sort them.
template <class Predicate> void partiallySort(size_type n, Predicate p) template <class Predicate> void partiallySort(size_type n, Predicate p)
{ {
std::partial_sort(begin(), begin() + n, end(), p); std::partial_sort(begin(), begin() + std::min(n, size()), end(), p);
} }
//! In-place partially sort by some particular key(s). //! In-place partially sort by some particular key(s).