![]() |
DSC Engine
|
Generic dynamic vector. More...
#include <vector.hpp>
Public Member Functions | |
| Vector (int size=0) | |
| Vector (const Vector< T > &vector) | |
| Vector (Vector< T > &&vector) | |
| template<typename... Args> | |
| Vector (T _first, Args... args) | |
| Vector< T > & | operator= (Vector< T > &&vector) |
| Vector< T > & | operator= (const Vector< T > &vector) |
| void | clear () |
| Sets all the elements in the vector to their default value determined by their type. More... | |
| void | reset () |
| Sets the vector to its initial state | |
| void | resize (int new_size) |
| Changes vector's number of elements. More... | |
| void | push_back (const T &item) |
| Adds new element to the end of the vector. More... | |
| T & | back () |
| Gets the last element in vector. More... | |
| int | index_of (const T &item) const |
| Finds the position of an item in the vector. More... | |
| bool | remove (const T &item) |
| Removes the first occurence of an element from the vector. More... | |
| void | remove_at (int index) |
| Removes the element at a given position. More... | |
| int | size () const |
| Gets the vector length. More... | |
| T & | operator[] (int index) |
| Random access index operator. More... | |
| const T & | operator[] (int index) const |
| Random access index operator. More... | |
| const T & | get_at (int index) const |
| Gets element at a certain index. More... | |
Generic dynamic vector.
| T | type of contained items |
| T & DSC::Vector< T >::back |
Gets the last element in vector.
| [output] | The element on the last position in vector |
Error is raised is the vector is empty
| void DSC::Vector< T >::clear |
Sets all the elements in the vector to their default value determined by their type.
Not to be confused with reset(), which also sets the vector to its initials size
| const T & DSC::Vector< T >::get_at | ( | int | index | ) | const |
Gets element at a certain index.
| [in] | index | Position in vector |
Range checks are performed only in debug mode.
| int DSC::Vector< T >::index_of | ( | const T & | item | ) | const |
Finds the position of an item in the vector.
| [in] | item | Item to be found |
| T & DSC::Vector< T >::operator[] | ( | int | index | ) |
Random access index operator.
| [in] | index | Position in vector |
Range checks are performed only in debug mode.
| const T & DSC::Vector< T >::operator[] | ( | int | index | ) | const |
Random access index operator.
| [in] | index | Position in vector |
Can be used as an lvalue e.g. v[i] = my_T_Element;
Range checks are performed only in debug mode.
| void DSC::Vector< T >::push_back | ( | const T & | item | ) |
Adds new element to the end of the vector.
| [in] | item | Element to be added |
| bool DSC::Vector< T >::remove | ( | const T & | item | ) |
Removes the first occurence of an element from the vector.
| [in] | item | Element to be removed |
| void DSC::Vector< T >::remove_at | ( | int | index | ) |
Removes the element at a given position.
| [in] | index | Position of the element to remove |
Range checks are performed only in debug mode.
| void DSC::Vector< T >::resize | ( | int | new_size | ) |
Changes vector's number of elements.
| [in] | new_cap | New vector size |
If the vector becomes smaller after this operation, the left-out elements are discarded
| int DSC::Vector< T >::size |
Gets the vector length.