UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
UN::HeapArray< T > Class Template Referencefinal

Fixed-size heap-allocated array. More...

#include <HeapArray.h>

Public Member Functions

 HeapArray ()=default
 Create an empty array.
 
 HeapArray (const HeapArray &other)
 Copy constructor.
 
 HeapArray (HeapArray &&other) noexcept
 Move constructor.
 
 HeapArray (const ArraySlice< const T > &data)
 Create an array. More...
 
HeapArrayoperator= (const HeapArray &other)
 Copy assignment.
 
HeapArrayoperator= (HeapArray &&other) noexcept
 Move assignment.
 
 HeapArray (IAllocator *pAllocator)
 Create an array. More...
 
 HeapArray (USize size, const T &value={})
 Create an array. More...
 
 HeapArray (IAllocator *pAllocator, USize size, const T &value={})
 Create an array. More...
 
void Resize (USize size, const T &value={})
 Set size of the array. More...
 
ArraySlice< T > operator() (USize beginIndex, USize endIndex) const noexcept
 Create a subslice from this array. More...
 
T & operator[] (USize index) const noexcept
 Get an element by index. More...
 
SSize IndexOf (const T &value) const
 Get index of the first element equal to the passed value. More...
 
SSize LastIndexOf (const T &value) const
 Get index of the last element equal to the passed value. More...
 
bool Contains (const T &value)
 Check if the element is present in the array. More...
 
USize Length () const
 \bried Length of the array.
 
bool Empty () const
 Check if the array is empty.
 
bool Any () const
 Check if the array has any elements.
 
void Reset ()
 Reset the array to empty state.
 
T * Data ()
 Get pointer to the beginning of the array.
 
const T * Data () const
 Get pointer to the beginning of the array.
 
USize CopyDataTo (ArraySlice< T > destination) const
 Copy data from this array to a slice. More...
 
const T * begin () const
 
const T * end () const
 
 operator ArraySlice< const T > () const
 
 operator ArraySlice< T > ()
 

Static Public Member Functions

static HeapArray< T > CopyFrom (const ArraySlice< const T > &arraySlice)
 Create a heap array by copying data from another container. More...
 

Detailed Description

template<class T>
class UN::HeapArray< T >

Fixed-size heap-allocated array.

This class is mostly used for interoperability with other languages, should not be used internally or in the user code, std::vector is preferred in such cases.

Constructor & Destructor Documentation

◆ HeapArray() [1/4]

template<class T >
UN::HeapArray< T >::HeapArray ( const ArraySlice< const T > &  data)
inlineexplicit

Create an array.

Parameters
data- An array slice to copy the data from.

◆ HeapArray() [2/4]

template<class T >
UN::HeapArray< T >::HeapArray ( IAllocator pAllocator)
inlineexplicit

Create an array.

Parameters
pAllocator- The allocator to use for heap allocations.

◆ HeapArray() [3/4]

template<class T >
UN::HeapArray< T >::HeapArray ( USize  size,
const T &  value = {} 
)
inlineexplicit

Create an array.

Parameters
size- The number of array elements.
value- The value to set to each element.

◆ HeapArray() [4/4]

template<class T >
UN::HeapArray< T >::HeapArray ( IAllocator pAllocator,
USize  size,
const T &  value = {} 
)
inline

Create an array.

Parameters
pAllocator- The allocator to use for heap allocations.
size- The number of array elements.
value- The value to set to each element.

Member Function Documentation

◆ Contains()

template<class T >
bool UN::HeapArray< T >::Contains ( const T &  value)
inline

Check if the element is present in the array.

Parameters
value- The value to look for.

◆ CopyDataTo()

template<class T >
USize UN::HeapArray< T >::CopyDataTo ( ArraySlice< T >  destination) const
inline

Copy data from this array to a slice.

Parameters
destination- The destination slice.
Returns
The number of actually copied elements.

◆ CopyFrom()

template<class T >
static HeapArray< T > UN::HeapArray< T >::CopyFrom ( const ArraySlice< const T > &  arraySlice)
inlinestatic

Create a heap array by copying data from another container.

Parameters
arraySlice- An ArraySlice with the data to be copied.

◆ IndexOf()

template<class T >
SSize UN::HeapArray< T >::IndexOf ( const T &  value) const
inline

Get index of the first element equal to the passed value.

Parameters
value- The value to look for.
Returns
The index of the value or -1.

◆ LastIndexOf()

template<class T >
SSize UN::HeapArray< T >::LastIndexOf ( const T &  value) const
inline

Get index of the last element equal to the passed value.

Parameters
value- The value to look for.
Returns
The index of the value or -1.

◆ operator()()

template<class T >
ArraySlice< T > UN::HeapArray< T >::operator() ( USize  beginIndex,
USize  endIndex 
) const
inlinenoexcept

Create a subslice from this array.

Parameters
beginIndex- The index of the first element.
endIndex- The index of the first element after the end.
Returns
The created subslice.

◆ operator[]()

template<class T >
T & UN::HeapArray< T >::operator[] ( USize  index) const
inlinenoexcept

Get an element by index.

Parameters
index- The index of the element to get.

◆ Resize()

template<class T >
void UN::HeapArray< T >::Resize ( USize  size,
const T &  value = {} 
)
inline

Set size of the array.

Parameters
size- The number of array elements.
value- The value to set to each new element.

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