mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
[algorithm] Add sort
This commit is contained in:
parent
11b604f45c
commit
2221c56fc5
@ -126,6 +126,32 @@ bool binary_search(span<SrcElementType, SrcExtent> rng, const T& value, Compare
|
|||||||
return std::binary_search(rng.data(), rng.data() + rng.size(), value, comp);
|
return std::binary_search(rng.data(), rng.data() + rng.size(), value, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort
|
||||||
|
template <class SrcElementType, std::ptrdiff_t SrcExtent>
|
||||||
|
void sort(span<SrcElementType, SrcExtent> rng)
|
||||||
|
{
|
||||||
|
std::sort(rng.data(), rng.data() + rng.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class SrcElementType, std::ptrdiff_t SrcExtent, class Compare>
|
||||||
|
void sort(span<SrcElementType, SrcExtent> rng, Compare comp)
|
||||||
|
{
|
||||||
|
std::sort(rng.data(), rng.data() + rng.size(), comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// stable sort
|
||||||
|
template <class SrcElementType, std::ptrdiff_t SrcExtent>
|
||||||
|
void stable_sort(span<SrcElementType, SrcExtent> rng)
|
||||||
|
{
|
||||||
|
std::stable_sort(rng.data(), rng.data() + rng.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class SrcElementType, std::ptrdiff_t SrcExtent, class Compare>
|
||||||
|
void stable_sort(span<SrcElementType, SrcExtent> rng, Compare comp)
|
||||||
|
{
|
||||||
|
std::stable_sort(rng.data(), rng.data() + rng.size(), comp);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gsl
|
} // namespace gsl
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user