#include <Vector.h>
|
| Vector () |
| Create a new empty vector.
|
|
| ~Vector () |
| Clean up vector data.
|
|
void | push (const T &value) |
| Adds a new element to the end of the vector.
|
|
T | pop () |
| Get the last element and remove it from the vector.
|
|
T & | operator[] (size_t index) |
| Write access to elements.
|
|
const T & | operator[] (size_t index) const |
| Read access to elements.
|
|
void | resize (size_t new_capacity) |
| Resize the max capacity for this vector.
|
|
void | clear () |
| Clear vector size for most vector methods.
|
|
size_t | getSize () const |
| Get the size of this vector.
|
|
size_t | getCapacity () const |
| Get the capacity of this vector.
|
|
void | insert (size_t pos, const T &value) |
| Insert an element anywhere in the vector.
|
|
void | erase (size_t pos) |
| Delete an element and shift the rest of the vector to fit.
|
|
T * | begin () |
|
T * | end () |
|
const T * | begin () const |
|
const T * | end () const |
|
template<typename T>
class tl::Vector< T >
Definition at line 7 of file Vector.h.
◆ Vector()
Create a new empty vector.
- Template Parameters
-
T | What type this vector will hold. |
Definition at line 38 of file Vector.h.
◆ ~Vector()
Clean up vector data.
- Template Parameters
-
T | How much memory is freed depends on the data type you used. |
Definition at line 49 of file Vector.h.
◆ begin() [1/2]
◆ begin() [2/2]
◆ clear()
Clear vector size for most vector methods.
- Template Parameters
-
T | Must match the type for this vector. |
Definition at line 132 of file Vector.h.
◆ end() [1/2]
◆ end() [2/2]
◆ erase()
Delete an element and shift the rest of the vector to fit.
- Template Parameters
-
T | T Must match the type for this vector. |
- Parameters
-
pos | Index of element to delete. |
When you erase an element, everything to the right of that element will be shifted left in the vector to not leave an empty space.
Definition at line 187 of file Vector.h.
◆ getCapacity()
Get the capacity of this vector.
- Template Parameters
-
T | Must match the type for this vector. |
- Returns
- Current capacity of vector.
Capacity is how big the internal array is for this vector. Good to check to make sure you don't go out of bounds with [].
Definition at line 157 of file Vector.h.
◆ getSize()
Get the size of this vector.
- Template Parameters
-
T | Must match the type for this vector. |
- Returns
- Current size of vector.
Size is based on how many elements actually exist in the vector.
Definition at line 144 of file Vector.h.
◆ insert()
template<typename T >
void tl::Vector< T >::insert |
( |
size_t | pos, |
|
|
const T & | value ) |
Insert an element anywhere in the vector.
- Template Parameters
-
T | T Must match the type for this vector. |
- Parameters
-
pos | Position to insert element at. |
value | Element to insert. |
Definition at line 168 of file Vector.h.
◆ operator[]() [1/2]
Write access to elements.
- Template Parameters
-
T | Must match the type for this vector. |
- Parameters
-
index | Element to overwrite. |
- Returns
- Reference to element to overwrite.
Definition at line 90 of file Vector.h.
◆ operator[]() [2/2]
template<typename T >
const T & tl::Vector< T >::operator[] |
( |
size_t | index | ) |
const |
Read access to elements.
- Template Parameters
-
T | Must match the type for this vector. |
- Parameters
-
- Returns
- Reference to element to read.
Definition at line 101 of file Vector.h.
◆ pop()
Get the last element and remove it from the vector.
- Template Parameters
-
T | Must match the type for this vector. |
- Returns
- The removed element.
Definition at line 75 of file Vector.h.
◆ push()
Adds a new element to the end of the vector.
- Template Parameters
-
T | Must match the type for this vector. |
- Parameters
-
Definition at line 62 of file Vector.h.
◆ resize()
template<typename T >
void tl::Vector< T >::resize |
( |
size_t | new_capacity | ) |
|
Resize the max capacity for this vector.
- Template Parameters
-
T | Must match the type for this vector. |
- Parameters
-
new_capacity | New capacity. |
If you don't use push or pop, you can also manually resize the vector with this, and can then access elements within capacity using [].
Definition at line 114 of file Vector.h.
The documentation for this class was generated from the following file: