BNM 2.4.0
 
Loading...
Searching...
No Matches
BNM::Structures::Mono::Array< T > Struct Template Reference

Array type implementation. More...

#include <BasicMonoStructures.hpp>

Public Member Functions

IL2CPP::il2cpp_array_size_t GetCapacity () const
 Get array size.
 
IL2CPP::il2cpp_array_size_t GetSize () const
 Get array size.
 
T * GetData () const
 Get array data pointer.
 
std::vector< T > ToVector () const
 Convert array to std::vector.
 
bool CopyFrom (const std::vector< T > &vec)
 Copy data from vector to current array.
 
bool CopyFrom (T *arr, IL2CPP::il2cpp_array_size_t size)
 Copy data from pointer to current array.
 
void CopyTo (T *arr) const
 Copy data from current array to some pointer.
 
Utils::DataIterator< T > At (IL2CPP::il2cpp_array_size_t index) const
 Get element at index.
 
Utils::DataIterator< T > operator[] (IL2CPP::il2cpp_array_size_t index) const
 
bool Empty () const
 Check if array is empty.
 
void Destroy ()
 Destroy array.
 
bool SelfCheck () const
 Check if array isn't null.
 
constexpr Array ()
 Create empty array.
 

Static Public Member Functions

static Array< T > * Create (size_t capacity, bool _forceUseAlloc=false)
 Creates new empty array of set capacity.
 
static Array< T > * Create (const std::vector< T > &vec, bool _forceUseAlloc=false)
 Creates new array using data from set vector.
 
static Array< T > * Create (T *arr, size_t size, bool _forceUseAlloc=false)
 Creates new array using data from set pointer.
 

Public Attributes

IL2CPP::Il2CppArrayBounds * bounds {}
 
IL2CPP::il2cpp_array_size_t capacity {}
 
m_Items [0]
 

Detailed Description

template<typename T>
struct BNM::Structures::Mono::Array< T >

Array type implementation.

Template Parameters
TElement type

Member Function Documentation

◆ At()

template<typename T>
Utils::DataIterator< T > BNM::Structures::Mono::Array< T >::At ( IL2CPP::il2cpp_array_size_t index) const
inline

Get element at index.

Returns
DataIterator of target element if array is valid and index isn't out of bounds, otherwise empty DataIterator.

◆ CopyFrom() [1/2]

template<typename T>
bool BNM::Structures::Mono::Array< T >::CopyFrom ( const std::vector< T > & vec)
inline

Copy data from vector to current array.

Parameters
vecSource vector
Returns
True if vector size is the same or less than array's size.

◆ CopyFrom() [2/2]

template<typename T>
bool BNM::Structures::Mono::Array< T >::CopyFrom ( T * arr,
IL2CPP::il2cpp_array_size_t size )
inline

Copy data from pointer to current array.

Parameters
arrSource pointer
sizeSource pointer size
Returns
True if size is the same or less than array's size.

◆ Create() [1/3]

template<typename T>
static Array< T > * BNM::Structures::Mono::Array< T >::Create ( const std::vector< T > & vec,
bool _forceUseAlloc = false )
inlinestatic

Creates new array using data from set vector.

Parameters
vecSource vector
_forceUseAllocForces code to create array using BNM::Allocate instead of BNM::Class::NewArray (Advanced usage only).
Returns
New array

◆ Create() [2/3]

template<typename T>
static Array< T > * BNM::Structures::Mono::Array< T >::Create ( size_t capacity,
bool _forceUseAlloc = false )
inlinestatic

Creates new empty array of set capacity.

Parameters
capacitySize of new array
_forceUseAllocForces code to create array using BNM::Allocate instead of BNM::Class::NewArray (Advanced usage only).
Returns
New array

◆ Create() [3/3]

template<typename T>
static Array< T > * BNM::Structures::Mono::Array< T >::Create ( T * arr,
size_t size,
bool _forceUseAlloc = false )
inlinestatic

Creates new array using data from set pointer.

Parameters
arrSource pointer
sizeSource pointer size
_forceUseAllocForces code to create array using BNM::Allocate instead of BNM::Class::NewArray (Advanced usage only).
Returns
New array

◆ Destroy()

template<typename T>
void BNM::Structures::Mono::Array< T >::Destroy ( )
inline

Destroy array.

Frees allocated memory for array.

Warning
Only for arrays created via BNM!

◆ Empty()

template<typename T>
bool BNM::Structures::Mono::Array< T >::Empty ( ) const
inlinenodiscard

Check if array is empty.

Returns
True if array isn't empty.

◆ GetCapacity()

template<typename T>
IL2CPP::il2cpp_array_size_t BNM::Structures::Mono::Array< T >::GetCapacity ( ) const
inlinenodiscard

Get array size.

Returns
Array size if it's valid, otherwise zero.

◆ GetData()

template<typename T>
T * BNM::Structures::Mono::Array< T >::GetData ( ) const
inlinenodiscard

Get array data pointer.

Returns
Array data pointer if array is valid, otherwise null.

◆ GetSize()

template<typename T>
IL2CPP::il2cpp_array_size_t BNM::Structures::Mono::Array< T >::GetSize ( ) const
inlinenodiscard

Get array size.

Alias of GetCapacity().

Returns
Array size if it's valid, otherwise zero.

◆ SelfCheck()

template<typename T>
bool BNM::Structures::Mono::Array< T >::SelfCheck ( ) const
inlinenodiscard

Check if array isn't null.

Checks if array is not null and logs if it's null. It's used mostly internally in debug builds to crash proof code.

Returns
True if string isn't null.

◆ ToVector()

template<typename T>
std::vector< T > BNM::Structures::Mono::Array< T >::ToVector ( ) const
inlinenodiscard

Convert array to std::vector.

Returns
Vector of elements if array is valid, otherwise empty vector.