13#include "Refureku/Containers/Allocator.h"
17 template <
typename T,
typename Allocator = rfk::Allocator<T>>
21 template <
typename U,
typename UAllocator>
25 using AllocTraits = std::allocator_traits<Allocator>;
28 static constexpr float const _growthFactor = 2.0f;
37 std::size_t _capacity;
48 void constructElements(T* from,
58 void copyElements(T
const* from,
70 void copyElementsReverse(T
const* from,
81 void moveElements(T* from,
93 void moveElementsReverse(T* from,
103 void destroyElements(T* from,
109 void checkedDelete();
117 void reallocateIfNecessary(std::size_t minCapacity);
127 void makeFreeSpaceForXElements(std::size_t index,
135 std::size_t computeNewCapacity(std::size_t minCapacity)
const noexcept;
138 using value_type = T;
140 using reference = value_type&;
141 using const_reference = value_type
const&;
143 Vector(std::size_t initialCapacity = 0u)
noexcept;
146 template <
typename U,
typename UAlloc>
160 T const&
front() const noexcept;
169 T const&
back() const noexcept;
177 T const*
data() const noexcept;
201 std::
size_t size() const noexcept;
269 template <typename... Args>
279 T const*
begin() const noexcept;
280 T const* cbegin() const noexcept;
288 T const*
end() const noexcept;
289 T const* cend() const noexcept;
298 T& operator[](std::
size_t index) noexcept;
299 T const& operator[](std::
size_t index) const noexcept;
305 #include "Refureku/Containers/Vector.inl"
Definition: Allocator.h:19
T * end() noexcept
Get a pointer past the last element.
void reserve(std::size_t capacity)
Reallocate the underlying memory to have enough space to fit capacity elements. No reallocation happe...
void insert(std::size_t index, T const &element)
Insert an element at a specified index.
std::size_t size() const noexcept
Get the number of elements stored in the vector.
void resize(std::size_t size)
Resize the vector so that it has exactly the specified size. Reallocation occurs if the size is great...
T & front() noexcept
Get a reference to the first element of the vector. The behaviour is undefined if the vector is empty...
T & back() noexcept
Get a reference to the last element of the vector. The behaviour is undefined if the vector is empty.
void clear()
Remove all elements from the vector.
Vector(Vector< U, UAlloc > &&) noexcept
bool empty() const noexcept
Check if the container contains no elements.
std::size_t capacity() const noexcept
Get the maximum number of elements storable in the vector without reallocation.
T * begin() noexcept
Get a pointer to the first element. If the vector is empty, the pointed memory is undefined.
void push_back(T const &value)
Add an element to the vector.
T * data() noexcept
Get a pointer to the underlying allocated memory.
T & emplace_back(Args &&... args)
Construct in place an element at the end of the vector with the provided arguments.
Definition: Allocator.h:16