BAN: Implement Vector::reverse()

This commit is contained in:
Bananymous 2024-09-14 19:44:04 +03:00
parent 2b52ea4c6f
commit dce2436b2c
1 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include <BAN/New.h>
#include <BAN/PlacementNew.h>
#include <BAN/Span.h>
#include <BAN/Swap.h>
namespace BAN
{
@ -65,6 +66,8 @@ namespace BAN
const T& front() const;
T& front();
void reverse();
ErrorOr<void> resize(size_type) requires is_default_constructible_v<T>;
ErrorOr<void> resize(size_type, const T&) requires is_copy_constructible_v<T>;
ErrorOr<void> reserve(size_type);
@ -301,6 +304,13 @@ namespace BAN
return m_data[0];
}
template<typename T>
void Vector<T>::reverse()
{
for (size_type i = 0; i < m_size / 2; i++)
BAN::swap(m_data[i], m_data[m_size - i - 1]);
}
template<typename T>
ErrorOr<void> Vector<T>::resize(size_type size) requires is_default_constructible_v<T>
{