mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
feat(kernel/std): add std::sort implementations
This commit is contained in:
parent
832833a56f
commit
d8cd27196d
@ -324,4 +324,42 @@ namespace std
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class RandomIt>
|
||||||
|
constexpr void sort(RandomIt first, RandomIt last)
|
||||||
|
{
|
||||||
|
if (first == last)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (RandomIt i = first; i != last; ++i)
|
||||||
|
{
|
||||||
|
for (RandomIt j = i + 1; j != last; ++j)
|
||||||
|
{
|
||||||
|
if (*j < *i)
|
||||||
|
std::swap(*i, *j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ExecutionPolicy, class RandomIt>
|
||||||
|
void sort(ExecutionPolicy &&policy, RandomIt first, RandomIt last);
|
||||||
|
|
||||||
|
template <class RandomIt, class Compare>
|
||||||
|
constexpr void sort(RandomIt first, RandomIt last, Compare comp)
|
||||||
|
{
|
||||||
|
if (first == last)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (RandomIt i = first; i != last; ++i)
|
||||||
|
{
|
||||||
|
for (RandomIt j = i + 1; j != last; ++j)
|
||||||
|
{
|
||||||
|
if (comp(*j, *i))
|
||||||
|
std::swap(*i, *j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ExecutionPolicy, class RandomIt, class Compare>
|
||||||
|
void sort(ExecutionPolicy &&policy, RandomIt first, RandomIt last, Compare comp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user