13 return "Vector out of range";
32 if (maxSize >= obj.size)
36 for (
int i=0; i<obj.size; i++)
49 template<
typename ... Args>
50 vector(Args&& ...args): buf(nullptr), size(0) {
52 reserve((
unsigned int)
sizeof...(Args));
59 if (
this == obj)
return *
this;
61 if (maxSize >= obj.size)
65 for (
int i=0; i<obj.size; i++)
76 if (amount <= maxSize)
return;
80 T* temp =
new T[amount];
83 for (
int i=0; i < size; i++)
98 if (newSize == maxSize)
return;
104 T* temp =
new T[newSize];
107 for (
int i=0; i < newSize; i++)
122 if (size >= maxSize) {
139 if (buf !=
nullptr) {
151 for (
int i = index; i < size - 1; i++) {
165 return buf[size - 1];
201 if (buf !=
nullptr) {
232 unsigned int size = 0;
234 unsigned int maxSize = 0;
265 return *_curr == *b._curr;
270 return _curr != b._curr;
Definition application.h:13
const char * what()
Definition vector.h:12
vector(vector &&obj)
Move Constructor.
Definition vector.h:41
T & back()
gives the last item.
Definition vector.h:164
~vector()
Deletes the allocated objects.
Definition vector.h:199
void remove(int index)
removes the item at the index
Definition vector.h:149
void clear()
clears the buffer
Definition vector.h:136
iterator end()
Definition vector.h:295
iterator begin() const
Definition vector.h:290
bool empty()
Returns if the size is <= 0.
Definition vector.h:182
T * data()
gives the internal buffer
Definition vector.h:174
void resize(unsigned int newSize)
Definition vector.h:95
vector(Args &&...args)
Initializes and calls push_back for all elements given.
Definition vector.h:50
iterator cend() const
Definition vector.h:311
T & at(int index)
returns the item at the desired index.
Definition vector.h:159
iterator begin()
Definition vector.h:284
vector()
Initializes the vector to empty.
Definition vector.h:27
unsigned int maxLength()
returns the maximum amount of objects in our internal buffer
Definition vector.h:187
void push_back(T obj)
Adds the new item to the array.
Definition vector.h:120
iterator cbegin() const
Definition vector.h:306
vector(const vector &obj)
Copy Constructor.
Definition vector.h:30
vector< T > & operator=(const vector< T > &obj)
Copies the obj.
Definition vector.h:58
unsigned int length()
returns the amount of objects in the internal buffer.
Definition vector.h:177
iterator end() const
Definition vector.h:301
T & operator[](int i)
Returns the obj for the given index.
Definition vector.h:192
void reserve(unsigned int amount)
allocates enough memory for the amount given.
Definition vector.h:73
void pop_back()
Removes the last item.
Definition vector.h:169
iterator & operator++()
Definition vector.h:246
bool operator==(const iterator &b) const
Definition vector.h:263
iterator & operator--()
Definition vector.h:252
T & operator*()
Definition vector.h:258
bool operator!=(const iterator &b) const
Definition vector.h:268
iterator(T *p)
Definition vector.h:242