mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Update STL headers
This commit is contained in:
@ -32,6 +32,16 @@ namespace std
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class BidirIt1, class BidirIt2>
|
||||
BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
*(--d_last) = *(--last);
|
||||
}
|
||||
return d_last;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void swap(T &a, T &b)
|
||||
{
|
||||
@ -65,6 +75,26 @@ namespace std
|
||||
: v;
|
||||
}
|
||||
|
||||
template <class ForwardIt1, class ForwardIt2>
|
||||
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
|
||||
ForwardIt2 s_first, ForwardIt2 s_last)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
ForwardIt1 it = first;
|
||||
for (ForwardIt2 s_it = s_first;; ++it, ++s_it)
|
||||
{
|
||||
if (s_it == s_last)
|
||||
return first;
|
||||
if (it == last)
|
||||
return last;
|
||||
if (!(*it == *s_it))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
template <class InputIt, class T>
|
||||
constexpr InputIt find(InputIt first, InputIt last, const T &value)
|
||||
{
|
||||
@ -95,6 +125,35 @@ namespace std
|
||||
return last;
|
||||
}
|
||||
|
||||
template <class ForwardIt1, class ForwardIt2>
|
||||
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
|
||||
ForwardIt2 s_first, ForwardIt2 s_last)
|
||||
{
|
||||
if (s_first == s_last)
|
||||
return last;
|
||||
ForwardIt1 result = last;
|
||||
while (true)
|
||||
{
|
||||
ForwardIt1 new_result = std::search(first, last, s_first, s_last);
|
||||
if (new_result == last)
|
||||
return result;
|
||||
result = new_result;
|
||||
first = new_result;
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class InputIt, class ForwardIt>
|
||||
InputIt find_first_of(InputIt first, InputIt last,
|
||||
ForwardIt s_first, ForwardIt s_last)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
for (ForwardIt it = s_first; it != s_last; ++it)
|
||||
if (*first == *it)
|
||||
return first;
|
||||
return last;
|
||||
}
|
||||
|
||||
template <class ForwardIt, class T>
|
||||
ForwardIt remove(ForwardIt first, ForwardIt last, const T &value)
|
||||
{
|
||||
@ -123,4 +182,15 @@ namespace std
|
||||
for (; first != last; ++first)
|
||||
*first = value;
|
||||
}
|
||||
|
||||
template <class OutputIt, class Size, class T>
|
||||
OutputIt fill_n(OutputIt first, Size count, const T &value)
|
||||
{
|
||||
for (Size i = 0; i < count; ++i)
|
||||
{
|
||||
*first = value;
|
||||
++first;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user