EHS
Loading...
Searching...
No Matches
ehs::Vector< T, N > Class Template Reference

#include <Vector.h>

Public Member Functions

 ~Vector ()
 Frees any data created on the heap.
 
 Vector ()
 Default members initialization.
 
 Vector (const N size, const N stride)
 
 Vector (std::initializer_list< T > list, const N stride=5)
 
 Vector (const T *data, const N size, const N stride)
 
 Vector (const Vector &vec)
 
 Vector (Vector &&vec) noexcept
 
Vectoroperator= (const Vector &vec)
 
Vectoroperator= (Vector &&vec) noexcept
 
bool operator== (const Vector &in) const
 
bool operator!= (const Vector &in) const
 
Vectoroperator+= (std::initializer_list< T > value)
 
Vectoroperator+= (const T value)
 
 operator T* () const
 Retrieves the raw C-style array from casting an array object.
 
RawSize () const
 
Size () const
 
Stride () const
 
End () const
 
void Copy (const N dstOffset, Vector< T, N > src, const N srcOffset=0)
 
void Copy (const N dstOffset, const T *src, const N inSize)
 
void Swap (N a, N b)
 
void Insert (const N index, const T value)
 
Remove (const N index)
 
void Push (const T *const value, const N size)
 
void Push (Vector< T > value)
 
void Push (std::initializer_list< T > value)
 
void Push (T value)
 
Pop ()
 
Pop (const N index)
 
void Resize (const N newSize)
 
void ExactSize ()
 Removes any extra allocated memory.
 
void Clear ()
 Releases the resources of the vector.
 

Protected Attributes

rawSize
 
size
 
stride
 
T * data
 

Detailed Description

template<typename T, typename N = UInt_64>
class ehs::Vector< T, N >

An array with extra memory pre-allocated for fast pushes.

Template Parameters
TArray data type to use.
NNumber data type to use.
Note
If extra memory is set to five then each time that memory is filled it will add five extra.

Constructor & Destructor Documentation

◆ ~Vector()

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::~Vector ( )
inline

Frees any data created on the heap.

◆ Vector() [1/6]

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::Vector ( )
inline

Default members initialization.

◆ Vector() [2/6]

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::Vector ( const N size,
const N stride )
inline

Initializes members for pre-allocated memory to write to later.

Parameters
[in]sizeThe size of memory to pre-allocate.
[in]strideThe stride size of memory to pre-allocate.

◆ Vector() [3/6]

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::Vector ( std::initializer_list< T > list,
const N stride = 5 )
inline

Initializes this vector with an initializer list object.

Parameters
[in]listThe given initializer list.
[in]strideThe extra amount of memory to allocate.

◆ Vector() [4/6]

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::Vector ( const T * data,
const N size,
const N stride )
inline

Initializes members with given C-style array.

Parameters
[in]dataThe C-style array.
[in]sizeThe size of the given C-style array.
[in]strideThe size of the extra memory allocated.

◆ Vector() [5/6]

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::Vector ( const Vector< T, N > & vec)
inline

Copies all members from the given vector object.

Parameters
[in]vecThe vector object to copy from.

◆ Vector() [6/6]

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::Vector ( Vector< T, N > && vec)
inlinenoexcept

Member Function Documentation

◆ Clear()

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Clear ( )
inline

Releases the resources of the vector.

◆ Copy() [1/2]

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Copy ( const N dstOffset,
const T * src,
const N inSize )
inline

Copies a C-style array with offsets.

Parameters
[in]dstOffsetThe offset index to copy the given C-style array to.
[in]srcThe given C-style array.
[in]sizeThe size from the given C-style array to copy.

◆ Copy() [2/2]

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Copy ( const N dstOffset,
Vector< T, N > src,
const N srcOffset = 0 )
inline

Copies a vector object with offsets.

Parameters
[in]dstOffsetThe offset index to copy the given vector object to.
[in]srcThe given vector object.
[in]srcOffsetThe offset index from the given vector object to copy from.

◆ End()

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::End ( ) const
inline

Retrieves the index at the end of the array.

Returns
The index.

◆ ExactSize()

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::ExactSize ( )
inline

Removes any extra allocated memory.

◆ Insert()

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Insert ( const N index,
const T value )
inline

Inserts a value at a specified index that is available.

Parameters
[in]indexThe index to insert the value at.
[in]valueThe given value to insert.

◆ operator T*()

template<typename T, typename N = UInt_64>
ehs::Vector< T, N >::operator T* ( ) const
inline

Retrieves the raw C-style array from casting an array object.

◆ operator!=()

template<typename T, typename N = UInt_64>
bool ehs::Vector< T, N >::operator!= ( const Vector< T, N > & in) const
inline

◆ operator+=() [1/2]

template<typename T, typename N = UInt_64>
Vector & ehs::Vector< T, N >::operator+= ( const T value)
inline

Adds a given value at the end of the vector.

Parameters
[in]valueThe given value to push to the end of the vector.

◆ operator+=() [2/2]

template<typename T, typename N = UInt_64>
Vector & ehs::Vector< T, N >::operator+= ( std::initializer_list< T > value)
inline

Adds a given initializer list at the end of the vector.

Parameters
[in]valueThe given initializer list to push to the end of the vector.

◆ operator=() [1/2]

template<typename T, typename N = UInt_64>
Vector & ehs::Vector< T, N >::operator= ( const Vector< T, N > & vec)
inline

Copies all members from the given vector object.

Parameters
[in]vecThe vector object to copy from.
Returns
The vector that has been assigned to.

◆ operator=() [2/2]

template<typename T, typename N = UInt_64>
Vector & ehs::Vector< T, N >::operator= ( Vector< T, N > && vec)
inlinenoexcept

◆ operator==()

template<typename T, typename N = UInt_64>
bool ehs::Vector< T, N >::operator== ( const Vector< T, N > & in) const
inline

◆ Pop() [1/2]

template<typename T, typename N = UInt_64>
T ehs::Vector< T, N >::Pop ( )
inline

Much like the stack it pops a value at the end of the vector.

Returns
The removed value.

◆ Pop() [2/2]

template<typename T, typename N = UInt_64>
T ehs::Vector< T, N >::Pop ( const N index)
inline

Will swap the value at the given index with the value at the end of the vector and pops it.

Parameters
[in]indexThe index of the value to swap with.
Returns
The removed value.

◆ Push() [1/4]

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Push ( const T *const value,
const N size )
inline

Adds a given C-style array at the end of the vector.

Parameters
[in]valueThe given C-style array to push to the end of the vector.
[in]sizeThe size of the given C-style array.

◆ Push() [2/4]

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Push ( std::initializer_list< T > value)
inline

Adds a given initializer at the end of the vector.

Parameters
[in]valueThe given initializer list to push to the end of the vector.

◆ Push() [3/4]

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Push ( T value)
inline

Adds a given value at the end of the vector.

Parameters
[in]valueThe given value to push to the end of the vector.

◆ Push() [4/4]

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Push ( Vector< T > value)
inline

Adds a given vector object at the end of the vector.

Parameters
[in]valueThe given vector object to push to the end of the vector.

◆ RawSize()

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::RawSize ( ) const
inline

Retrieves the size of the vector object including the extra memory allocated.

Returns
The raw size.

◆ Remove()

template<typename T, typename N = UInt_64>
T ehs::Vector< T, N >::Remove ( const N index)
inline

Removes a value at a specified index.

Parameters
[in]indexThe index to remove the value at.
Returns
The removed data.

◆ Resize()

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Resize ( const N newSize)
inline

Resizes the vector while keeping its alignment.

Parameters
[in]newSizeThe size to change to.

◆ Size()

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::Size ( ) const
inline

Retrieves the size of the array not including the extra memory allocated.

Returns
The size.

◆ Stride()

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::Stride ( ) const
inline

Retrieves the size of the extra memory allocated.

Returns
The extra size.

◆ Swap()

template<typename T, typename N = UInt_64>
void ehs::Vector< T, N >::Swap ( N a,
N b )
inline

Swaps two values in the vector.

Parameters
[in]aThe first index to swap with.
[in]bThe second index to swap with.

Member Data Documentation

◆ data

template<typename T, typename N = UInt_64>
T* ehs::Vector< T, N >::data
protected

◆ rawSize

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::rawSize
protected

◆ size

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::size
protected

◆ stride

template<typename T, typename N = UInt_64>
N ehs::Vector< T, N >::stride
protected

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