KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
KarmaVector< BuildingBlock > Class Template Reference

Karma's std::vector wrapper. More...

#include <KarmaTypes.h>

Public Member Functions

 KarmaVector ()
 Constructor.
 
 ~KarmaVector ()
 Destructor.
 
uint32_t Remove (BuildingBlock aBlock)
 Removes an element from the vector.
 
void Add (BuildingBlock aBlock)
 Add an element to the vector.
 
FORCEINLINE int32_t AddUnique (const BuildingBlock &Item)
 
int32_t Find (const BuildingBlock &Item) const
 
bool Contains (BuildingBlock aBlock) const
 Sees if the vector contains the specified element.
 
uint32_t Num () const
 Returns the total number of elements in a vector.
 
void Reset ()
 We just reset the vector. UE has the following implementation.
 
void SmartReset ()
 Just clear the elements.
 
void SetVectorElementByIndex (int32_t Index, BuildingBlock Value)
 Set the element of a vector using the vector index.
 
const std::vector< BuildingBlock > & GetElements () const
 Getter for the elements of vector.
 
std::vector< BuildingBlock > & ModifyElements ()
 Getter for elements of vector for modification in appropriate way.
 
std::vector< BuildingBlock >::iterator begin ()
 Getter for first vector element.
 
std::vector< BuildingBlock >::iterator end ()
 Getter for the last vector element.
 
FORCEINLINE BuildingBlock & IndexToObject (int32_t Index)
 
FORCEINLINE bool IsValidIndex (int32_t Index) const
 

Protected Attributes

std::vector< BuildingBlock > m_Elements
 

Detailed Description

template<typename BuildingBlock>
class KarmaVector< BuildingBlock >

Karma's std::vector wrapper.

Constructor & Destructor Documentation

◆ KarmaVector()

template<typename BuildingBlock>
KarmaVector< BuildingBlock >::KarmaVector ( )
inline

Constructor.

Since
Karma 1.0.0

◆ ~KarmaVector()

template<typename BuildingBlock>
KarmaVector< BuildingBlock >::~KarmaVector ( )
inline

Destructor.

Since
Karma 1.0.0

Member Function Documentation

◆ Add()

template<typename BuildingBlock>
void KarmaVector< BuildingBlock >::Add ( BuildingBlock aBlock)
inline

Add an element to the vector.

@aBlock The element to be added

Since
Karma 1.0.0

◆ AddUnique()

template<typename BuildingBlock>
FORCEINLINE int32_t KarmaVector< BuildingBlock >::AddUnique ( const BuildingBlock & Item)
inline

Adds unique element to array if it doesn't exist.

Move semantics version.

Parameters
ItemItem to add.
Returns
Index of the element in the array.
See also
Add, AddDefaulted, AddZeroed, Append, Insert
Since
Karma 1.0.0

◆ begin()

template<typename BuildingBlock>
std::vector< BuildingBlock >::iterator KarmaVector< BuildingBlock >::begin ( )
inline

Getter for first vector element.

Since
Karma 1.0.0

◆ Contains()

template<typename BuildingBlock>
bool KarmaVector< BuildingBlock >::Contains ( BuildingBlock aBlock) const
inline

Sees if the vector contains the specified element.

Parameters
aBlockThe element to be see in the vector
Returns
true if the element exists in the vector
Since
Karam 1.0.0

◆ end()

template<typename BuildingBlock>
std::vector< BuildingBlock >::iterator KarmaVector< BuildingBlock >::end ( )
inline

Getter for the last vector element.

Since
Karma 1.0.0

◆ Find()

template<typename BuildingBlock>
int32_t KarmaVector< BuildingBlock >::Find ( const BuildingBlock & Item) const
inline

Finds element within the array.

Parameters
ItemItem to look for.
Returns
Index of the found element. INDEX_NONE otherwise.
See also
FindLast, FindLastByPredicate
https://www.techiedelight.com/find-index-element-vector-cpp/
Since
Karma 1.0.0

◆ GetElements()

template<typename BuildingBlock>
const std::vector< BuildingBlock > & KarmaVector< BuildingBlock >::GetElements ( ) const
inline

Getter for the elements of vector.

Since
Karma 1.0.0

◆ IndexToObject()

template<typename BuildingBlock>
FORCEINLINE BuildingBlock & KarmaVector< BuildingBlock >::IndexToObject ( int32_t Index)
inline

Returns the UObject corresponding to index. Be advised this is only for very low level use.

Parameters
Indexindex of object to return
Returns
Object at this index
Since
Karma 1.0.0

◆ IsValidIndex()

template<typename BuildingBlock>
FORCEINLINE bool KarmaVector< BuildingBlock >::IsValidIndex ( int32_t Index) const
inline

Tests if index is valid, i.e. greater than or equal to zero, and less than the number of elements in the array.

Parameters
IndexIndex to test.
Returns
True if index is valid. False otherwise.
Since
Karma 1.0.0

◆ ModifyElements()

template<typename BuildingBlock>
std::vector< BuildingBlock > & KarmaVector< BuildingBlock >::ModifyElements ( )
inline

Getter for elements of vector for modification in appropriate way.

Remarks
A modifyable reference is returned
Since
Karma 1.0.0

◆ Num()

template<typename BuildingBlock>
uint32_t KarmaVector< BuildingBlock >::Num ( ) const
inline

Returns the total number of elements in a vector.

Since
Karma 1.0.0

◆ Remove()

template<typename BuildingBlock>
uint32_t KarmaVector< BuildingBlock >::Remove ( BuildingBlock aBlock)
inline

Removes an element from the vector.

Parameters
aBlockThe element to be removed
Since
Karma 1.0.0

◆ Reset()

template<typename BuildingBlock>
void KarmaVector< BuildingBlock >::Reset ( )
inline

We just reset the vector. UE has the following implementation.

Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array. It calls the destructors on held items if needed and then zeros the ArrayNum.

Parameters
NewSizeThe expected usage size after calling this function.
Warning
Included deletion of possible UObjects. Hence needs rewriting once ShivaActor is functional
Since
Karma 1.0.0

◆ SetVectorElementByIndex()

template<typename BuildingBlock>
void KarmaVector< BuildingBlock >::SetVectorElementByIndex ( int32_t Index,
BuildingBlock Value )
inline

Set the element of a vector using the vector index.

Parameters
IndexThe index of the vector element to be set
ValueThe value to be assigned to the element
Since
Karma 1.0.0

◆ SmartReset()

template<typename BuildingBlock>
void KarmaVector< BuildingBlock >::SmartReset ( )
inline

Just clear the elements.

Remarks
Assuming the use of smart pointers
Warning
Still need to think deletion of UObjects
Since
Karma 1.0.0

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