3#include "Internal/Memory/Buffer.hpp"
21 self.buf.resize(self.__capacity);
29 : obj_count(0), __capacity(1)
36 template<Typing::USize N>
44 this->buf[i] = objects[i];
52 this->buf = other.buf;
53 this->__capacity = other.__capacity;
54 this->obj_count = other.obj_count;
61 this->buf = std::move(other.buf);
62 this->__capacity = other.__capacity;
63 this->obj_count = other.obj_count;
73 return self.buf.begin();
80 return self.buf.begin() + self.obj_count;
90 if (self.obj_count >= self.__capacity)
93 self.buf[self.obj_count++] = object;
101 template<
typename... ARGS>
104 if (self.obj_count >= self.__capacity)
107 self.buf[self.obj_count] = T(args...);
118 if (self.obj_count > 0) {
120 T &obj = self.buf[self.obj_count];
131 if (index >= self.obj_count)
135 self.buf[i] = self.buf[i + 1];
143 self.buf.set(0, self.buf.size());
151 return self.buf.get();
166 return self.obj_count;
173 return self.__capacity;
180 return self.obj_count == 0;
190 return self.buf == other.buf;
197 return self.buf[index];
204 return self.buf[index];
212 if (&self != &other) {
213 self.buf = other.buf;
214 self.__capacity = other.__capacity;
215 self.obj_count = other.obj_count;
226 if (&self != &other) {
227 self.buf = std::move(other.buf);
228 self.__capacity = other.__capacity;
229 self.obj_count = other.obj_count;
231 other.__capacity = 0;
Thrown when an index is out of range.
Definition OutOfRange.hpp:11
Container for raw memory.
Definition Buffer.hpp:18
Vector(const Vector< T > &other)
Copy constructor.
Definition Vector.hpp:50
void erase(this Vector< T > &self, Typing::USize index)
Erases object at a given position in the vector.
Definition Vector.hpp:129
Vector(const T(&objects)[N])
Constructs the vector from existing objects.
Definition Vector.hpp:37
const T * data(this const Vector< T > &self)
Gets a pointer to the internal buffer storage.
Definition Vector.hpp:149
Vector< T > & operator=(this Vector< T > &self, const Vector< T > &other)
Copy assignment operator.
Definition Vector.hpp:210
Vector(Vector< T > &&other)
Move constructor.
Definition Vector.hpp:59
Memory::Buffer< T > toBuffer(this const Vector< T > &self)
Gets a copy of the internal buffer.
Definition Vector.hpp:156
void emplaceBack(this Vector< T > &self, ARGS &&...args)
Constructs an object and add it at the end of the vector.
Definition Vector.hpp:102
Vector()
Default constructor.
Definition Vector.hpp:28
const T * begin(this const Vector< T > &self)
Gets a pointer to the base of the data.
Definition Vector.hpp:71
T & operator[](this Vector< T > &self, Typing::USize index)
Gets an object from the vector.
Definition Vector.hpp:195
void pushBack(this Vector< T > &self, const T &object)
Add an object to the end of the vector.
Definition Vector.hpp:88
Typing::USize length(this const Vector< T > &self)
Gets the length of the vector.
Definition Vector.hpp:164
bool isEmpty(this const Vector< T > &self)
Checks if the vector is empty.
Definition Vector.hpp:178
const T * end(this const Vector< T > &self)
Gets a pointer to the end of the data.
Definition Vector.hpp:78
bool operator==(this const Vector< T > &self, const Vector< T > &other)
Checks if both buffers are the same.
Definition Vector.hpp:188
Typing::USize capacity(this const Vector< T > &self)
Gets the capacity of the vector.
Definition Vector.hpp:171
T & popBack(this Vector< T > &self)
Removes the last object from the vector.
Definition Vector.hpp:116
void clear(this Vector< T > &self)
Clears the vector.
Definition Vector.hpp:141
size_t USize
Biggest unsigned type.
Definition Typing.hpp:38
Contains dynamic vector manipulation features.
Definition Vector.hpp:8