Urho3D
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | List of all members
Urho3D::Vector< T > Class Template Reference

Vector template class. More...

#include </home/runner/work/urho3d-doxygen.github.io/urho3d-doxygen.github.io/urho3d_repo/Source/Urho3D/Container/Vector.h>

Inheritance diagram for Urho3D::Vector< T >:
Urho3D::VectorBase

Classes

struct  CopyTag
 
struct  MoveTag
 

Public Types

using ValueType = T
 
using Iterator = RandomAccessIterator< T >
 
using ConstIterator = RandomAccessConstIterator< T >
 

Public Member Functions

 Vector () noexcept=default
 Construct empty.
 
 Vector (i32 size)
 Construct with initial size.
 
 Vector (i32 size, const T &value)
 Construct with initial size and default value.
 
 Vector (const T *data, i32 size)
 Construct with initial data.
 
 Vector (const Vector< T > &vector)
 Copy-construct from another vector.
 
 Vector (ConstIterator start, ConstIterator end)
 Copy-construct from another vector (iterator version).
 
 Vector (Vector< T > &&vector)
 Move-construct from another vector.
 
 Vector (const std::initializer_list< T > &list)
 Aggregate initialization constructor.
 
 ~Vector ()
 Destruct.
 
Vector< T > & operator= (const Vector< T > &rhs)
 Assign from another vector.
 
Vector< T > & operator= (Vector< T > &&rhs)
 Move-assign from another vector.
 
Vector< T > & operator+= (const T &rhs)
 Add-assign an element.
 
Vector< T > & operator+= (const Vector< T > &rhs)
 Add-assign another vector.
 
Vector< T > operator+ (const T &rhs) const
 Add an element.
 
Vector< T > operator+ (const Vector< T > &rhs) const
 Add another vector.
 
bool operator== (const Vector< T > &rhs) const
 Test for equality with another vector.
 
bool operator!= (const Vector< T > &rhs) const
 Test for inequality with another vector.
 
T & operator[] (i32 index)
 Return element at index.
 
const T & operator[] (i32 index) const
 Return const element at index.
 
T & At (i32 index)
 Return element at index.
 
const T & At (i32 index) const
 Return const element at index.
 
template<class... Args>
T & EmplaceBack (Args &&... args)
 Create an element at the end.
 
void Push (const T &value)
 Add an element at the end.
 
void Push (T &&value)
 Move-add an element at the end.
 
void Push (const Vector< T > &vector)
 Add another vector at the end.
 
void Pop ()
 Remove the last element.
 
void Insert (i32 pos, const T &value)
 Insert an element at position. If pos is ENDPOS, append the new value at the end.
 
void Insert (i32 pos, T &&value)
 Insert an element at position. If pos is ENDPOS, append the new value at the end.
 
void Insert (i32 pos, const Vector< T > &vector)
 Insert another vector at position. If pos is ENDPOS, append the new elements at the end.
 
Iterator Insert (const Iterator &dest, const T &value)
 Insert an element by iterator.
 
Iterator Insert (const Iterator &dest, T &&value)
 Move-insert an element by iterator.
 
Iterator Insert (const Iterator &dest, const Vector< T > &vector)
 Insert a vector by iterator.
 
Iterator Insert (const Iterator &dest, const ConstIterator &start, const ConstIterator &end)
 Insert a vector partially by iterators.
 
Iterator Insert (const Iterator &dest, const T *start, const T *end)
 Insert elements.
 
void Erase (i32 pos, i32 length=1)
 Erase a range of elements.
 
void EraseSwap (i32 pos, i32 length=1)
 Erase a range of elements by swapping elements from the end of the array.
 
Iterator Erase (const Iterator &it)
 Erase an element by iterator. Return iterator to the next element.
 
Iterator Erase (const Iterator &start, const Iterator &end)
 Erase a range by iterators. Return iterator to the next element.
 
bool Remove (const T &value)
 Erase an element by value. Return true if was found and erased.
 
bool RemoveSwap (const T &value)
 Erase an element by value by swapping with the last element. Return true if was found and erased.
 
void Clear ()
 Clear the vector.
 
void Resize (i32 newSize)
 Resize the vector.
 
void Resize (i32 newSize, const T &value)
 Resize the vector and fill new elements with default value.
 
void Reserve (i32 newCapacity)
 Set new capacity.
 
void Compact ()
 Reallocate so that no extra memory is used.
 
Iterator Find (const T &value)
 Return iterator to value, or to the end if not found.
 
ConstIterator Find (const T &value) const
 Return const iterator to value, or to the end if not found.
 
i32 IndexOf (const T &value) const
 Return index of value in vector, or size if not found.
 
bool Contains (const T &value) const
 Return whether contains a specific value.
 
Iterator Begin ()
 Return iterator to the beginning.
 
ConstIterator Begin () const
 Return const iterator to the beginning.
 
Iterator End ()
 Return iterator to the end.
 
ConstIterator End () const
 Return const iterator to the end.
 
T & Front ()
 Return first element.
 
const T & Front () const
 Return const first element.
 
T & Back ()
 Return last element.
 
const T & Back () const
 Return const last element.
 
i32 Size () const
 Return number of elements.
 
i32 Capacity () const
 Return capacity of vector.
 
bool Empty () const
 Return whether vector is empty.
 
T * Buffer () const
 Return the buffer with right type.
 
- Public Member Functions inherited from Urho3D::VectorBase
 VectorBase () noexcept
 Construct.
 
void Swap (VectorBase &rhs)
 Swap with another vector.
 

Private Member Functions

void DoResize (i32 newSize)
 Resize the vector and create/remove new elements as necessary.
 
template<class Tag , class RandomIteratorT >
Iterator DoInsertElements (i32 pos, RandomIteratorT start, RandomIteratorT end, Tag)
 Insert elements into the vector using copy or move constructor. If pos is ENDPOS, append the new elements at the end.
 
Iterator DoEraseElements (i32 pos, i32 count)
 Erase elements from the vector.
 
void MoveRange (i32 dest, i32 src, i32 count)
 Move a range of elements within the vector. Only for POD Vector.
 

Static Private Member Functions

static void ConstructElements (T *dest, i32 count)
 Construct elements using default ctor.
 
template<class RandomIteratorT >
static void ConstructElements (T *dest, RandomIteratorT start, RandomIteratorT end, CopyTag)
 Copy-construct elements.
 
template<class RandomIteratorT >
static void ConstructElements (T *dest, RandomIteratorT start, RandomIteratorT end, MoveTag)
 Move-construct elements.
 
static i32 CalculateCapacity (i32 size, i32 capacity)
 Calculate new vector capacity.
 
static void DestructElements (T *dest, i32 count)
 Call the elements' destructors.
 
static void CopyElements (T *dest, const T *src, i32 count)
 Copy elements from one buffer to another. Only for POD Vector.
 

Additional Inherited Members

- Static Protected Member Functions inherited from Urho3D::VectorBase
static u8 * AllocateBuffer (i32 size)
 
- Protected Attributes inherited from Urho3D::VectorBase
i32 size_
 Size of vector.
 
i32 capacity_
 Buffer capacity.
 
u8 * buffer_
 Buffer.
 

Detailed Description

template<class T>
class Urho3D::Vector< T >

Vector template class.


The documentation for this class was generated from the following file: