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

This class represents a non-owning slice of contiguously stored elements. More...

#include <ArraySlice.h>

Public Member Functions

 ArraySlice (T *pData, USize count) noexcept
 Create an array slice. More...
 
 ArraySlice (T *pBegin, T *pEnd) noexcept
 Create an array slice. More...
 
template<USize N>
 ArraySlice (T(&arr)[N]) noexcept
 Create an array slice. More...
 
 ArraySlice (StdVector &vector) noexcept
 Create an array slice. More...
 
template<USize N>
 ArraySlice (StdArray< N > &array) noexcept
 Create an array slice. More...
 
 ArraySlice (std::initializer_list< T > lst) noexcept
 Create an array slice. More...
 
ArraySlice operator() (USize beginIndex, USize endIndex) const
 Create a subslice from this array slice. More...
 
T & operator[] (USize index) const
 Get an element by index. More...
 
SSize IndexOf (const T &value) const noexcept
 Get index of the first element equal to the passed value. More...
 
SSize LastIndexOf (const T &value) const noexcept
 Get index of the last element equal to the passed value. More...
 
bool Contains (const T &value) const noexcept
 Check if the element is present in the slice. More...
 
USize Length () const noexcept
 Length of the slice.
 
bool Empty () const noexcept
 Check if the slice is empty.
 
bool Any () const noexcept
 Check if the slice has any elements.
 
void Reset () noexcept
 Reset the slice to empty state.
 
T * Data () const noexcept
 Get pointer to the beginning of the slice.
 
USize CopyDataTo (ArraySlice< std::remove_const_t< T > > destination) const
 Copy data from this slice to another. More...
 
template<class T1 >
ArraySlice< T1 > ReinterpretAs () const
 
const T * begin () const noexcept
 
const T * end () const noexcept
 
 operator ArraySlice< std::add_const_t< T > > () const noexcept
 

Friends

bool operator== (const ArraySlice &lhs, const ArraySlice &rhs) noexcept
 
bool operator!= (const ArraySlice &lhs, const ArraySlice &rhs) noexcept
 

Detailed Description

template<class T>
class UN::ArraySlice< T >

This class represents a non-owning slice of contiguously stored elements.

Constructor & Destructor Documentation

◆ ArraySlice() [1/6]

template<class T >
UN::ArraySlice< T >::ArraySlice ( T *  pData,
USize  count 
)
inlinenoexcept

Create an array slice.

Parameters
pData- The pointer to the first element.
count- The number of elements.

◆ ArraySlice() [2/6]

template<class T >
UN::ArraySlice< T >::ArraySlice ( T *  pBegin,
T *  pEnd 
)
inlinenoexcept

Create an array slice.

Parameters
pBegin- The pointer to the first element.
pEnd- The pointer to the first element after the end.

◆ ArraySlice() [3/6]

template<class T >
template<USize N>
UN::ArraySlice< T >::ArraySlice ( T(&)  arr[N])
inlinenoexcept

Create an array slice.

Template Parameters
N- The number of elements.
Parameters
arr- The source array.

◆ ArraySlice() [4/6]

template<class T >
UN::ArraySlice< T >::ArraySlice ( StdVector &  vector)
inlinenoexcept

Create an array slice.

Parameters
vector- The vector to create the slice from.

◆ ArraySlice() [5/6]

template<class T >
template<USize N>
UN::ArraySlice< T >::ArraySlice ( StdArray< N > &  array)
inlinenoexcept

Create an array slice.

Template Parameters
N- The number of elements.
Parameters
array- The array to create the slice from.

◆ ArraySlice() [6/6]

template<class T >
UN::ArraySlice< T >::ArraySlice ( std::initializer_list< T >  lst)
inlinenoexcept

Create an array slice.

Parameters
lst- The initializer list to create the slice from.
Note
The created instance will only be valid if passed as a parameter.

Member Function Documentation

◆ Contains()

template<class T >
bool UN::ArraySlice< T >::Contains ( const T &  value) const
inlinenoexcept

Check if the element is present in the slice.

Parameters
value- The value to look for.

◆ CopyDataTo()

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

Copy data from this slice to another.

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

◆ IndexOf()

template<class T >
SSize UN::ArraySlice< T >::IndexOf ( const T &  value) const
inlinenoexcept

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::ArraySlice< T >::LastIndexOf ( const T &  value) const
inlinenoexcept

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 UN::ArraySlice< T >::operator() ( USize  beginIndex,
USize  endIndex 
) const
inline

Create a subslice from this array slice.

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::ArraySlice< T >::operator[] ( USize  index) const
inline

Get an element by index.

Parameters
index- The index of the element to get.

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