ULIS  dev4.0.7
Utility Library for Imaging Systems
Public Member Functions | List of all members
TArray< T > Class Template Reference

The TArray class provides a simple dynamic array or vector class for ULIS interfaces. More...

Public Member Functions

 TArray ()
 
 TArray (const TArray< T > &iOther)=delete
 
 TArray (TArray< T > &&iOther) noexcept
 
 TArray (uint64 iSize)
 
 ~TArray ()
 
T & At (uint64 iIndex)
 
const T & At (uint64 iIndex) const
 
T & Back ()
 
const T & Back () const
 
uint8Bits ()
 
const uint8Bits () const
 
uint64 Capacity () const
 
void Clear ()
 
T * Data ()
 
const T * Data () const
 
template<class ... Args>
void Emplace (uint64 iPos, Args &&... args)
 
template<class ... Args>
void EmplaceBack (Args &&... args)
 
void Erase (const T &iElement)
 
void Erase (uint64 iPos, uint64 iCount=1)
 
T & Front ()
 
const T & Front () const
 
void Insert (uint64 iPos, const T &iValue)
 
void Insert (uint64 iPos, T &&iValue)
 
void Insert (uint64 iPos, uint64 iCount, const T &iValue)
 
bool IsEmpty () const
 
TArray< T > & operator= (const TArray< T > &iOther)=delete
 
TArray< T > & operator= (TArray< T > &&iOther)=delete
 
T & operator[] (uint64 iIndex)
 
const T & operator[] (uint64 iIndex) const
 
void PopBack ()
 
void PushBack (const T &iValue=T())
 
void PushBack (T &&iValue)
 
void Reserve (uint64 iCapacity)
 
void Resize (uint64 iSize)
 
void Shrink ()
 
uint64 Size () const
 

Detailed Description

template<typename T>
class TArray< T >

The need of a custom TArray class rose from the fact that std:: classes cannot be exported easily accross dll boundaries when ULIS is compiled as a shared library.

Constructor & Destructor Documentation

◆ ~TArray()

template<typename T>
TArray< T >::~TArray ( )
inline

Destroy the Array and cleanup memory.

◆ TArray() [1/4]

template<typename T>
TArray< T >::TArray ( )
inline

Default constructor with size 0, capicity 0, uninitialized.

◆ TArray() [2/4]

template<typename T>
TArray< T >::TArray ( uint64  iSize)
inline

Constructor with known size, both capacity and size will match the requested size. The array will have a size of iSize and the elements are default constructed.

◆ TArray() [3/4]

template<typename T>
TArray< T >::TArray ( const TArray< T > &  iOther)
delete

Copy constructor, explicitly removed.

◆ TArray() [4/4]

template<typename T>
TArray< T >::TArray ( TArray< T > &&  iOther)
inlinenoexcept

Move constructor. The first object is left in a valid but empty state. The second object steals the buffer and the state ( size and capacity ).

Member Function Documentation

◆ At() [1/2]

template<typename T>
T& TArray< T >::At ( uint64  iIndex)
inline

Access component at index. Alias of operator[]()

See also
operator[]()

◆ At() [2/2]

template<typename T>
const T& TArray< T >::At ( uint64  iIndex) const
inline

Access component at index. Alias of operator[]()

See also
operator[]() const

◆ Back() [1/2]

template<typename T>
T& TArray< T >::Back ( )
inline

Access component at back. The behaviour is undefined if the array is empty.

◆ Back() [2/2]

template<typename T>
const T& TArray< T >::Back ( ) const
inline

Access const component at back. The behaviour is undefined if the array is empty.

◆ Bits() [1/2]

template<typename T>
uint8* TArray< T >::Bits ( )
inline

Returns the raw bits.

◆ Bits() [2/2]

template<typename T>
const uint8* TArray< T >::Bits ( ) const
inline

Returns the const raw bits.

◆ Capacity()

template<typename T>
uint64 TArray< T >::Capacity ( ) const
inline

Returns the array capacity.

◆ Clear()

template<typename T>
void TArray< T >::Clear ( )
inline

Clear the array, deallocating everything.

◆ Data() [1/2]

template<typename T>
T* TArray< T >::Data ( )
inline

Returns the storage.

◆ Data() [2/2]

template<typename T>
const T* TArray< T >::Data ( ) const
inline

Returns the const storage.

◆ Emplace()

template<typename T>
template<class ... Args>
void TArray< T >::Emplace ( uint64  iPos,
Args &&...  args 
)
inline

Emplace, emplace a new element at pos in the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ EmplaceBack()

template<typename T>
template<class ... Args>
void TArray< T >::EmplaceBack ( Args &&...  args)
inline

EmplaceBack, emplace a new element at the end of the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ Erase() [1/2]

template<typename T>
void TArray< T >::Erase ( const T &  iElement)
inline

Erase first found element, if found in the array. Behaviour is undefined if the array is empty. Does nothing if such element is not in the array.

◆ Erase() [2/2]

template<typename T>
void TArray< T >::Erase ( uint64  iPos,
uint64  iCount = 1 
)
inline

Erase elements at pos in the array. Behaviour is undefined if the array is empty.

◆ Front() [1/2]

template<typename T>
T& TArray< T >::Front ( )
inline

Access component at front. The behaviour is undefined if the array is empty.

◆ Front() [2/2]

template<typename T>
const T& TArray< T >::Front ( ) const
inline

Access const component at front. The behaviour is undefined if the array is empty.

◆ Insert() [1/3]

template<typename T>
void TArray< T >::Insert ( uint64  iPos,
const T &  iValue 
)
inline

Insert, insert a new element at pos in the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ Insert() [2/3]

template<typename T>
void TArray< T >::Insert ( uint64  iPos,
T &&  iValue 
)
inline

Insert, insert a new element at pos in the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ Insert() [3/3]

template<typename T>
void TArray< T >::Insert ( uint64  iPos,
uint64  iCount,
const T &  iValue 
)
inline

Insert, insert count new elements at pos in the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ IsEmpty()

template<typename T>
bool TArray< T >::IsEmpty ( ) const
inline

Returns wether the array is empty or not.

◆ operator=() [1/2]

template<typename T>
TArray< T >& TArray< T >::operator= ( const TArray< T > &  iOther)
delete

Copy Assignment Operator, explicitly removed.

◆ operator=() [2/2]

template<typename T>
TArray< T >& TArray< T >::operator= ( TArray< T > &&  iOther)
delete

Move Assignment Operator, explicitly removed.

◆ operator[]() [1/2]

template<typename T>
T& TArray< T >::operator[] ( uint64  iIndex)
inline

Access component at index. The behaviour is undefined if the array has no size. The behaviour is undefined if the index is greater than the size. The behaviour is undefined if the underlying buffer is nullptr, which indicates a corrupted states anyway.

◆ operator[]() [2/2]

template<typename T>
const T& TArray< T >::operator[] ( uint64  iIndex) const
inline

Access const component at index. The behaviour is undefined if the array has no size. The behaviour is undefined if the index is greater than the size. The behaviour is undefined if the underlying buffer is nullptr, which indicates a corrupted states anyway.

◆ PopBack()

template<typename T>
void TArray< T >::PopBack ( )
inline

PopBack, remove last element. Behaviour is undefined if the array is empty.

◆ PushBack() [1/2]

template<typename T>
void TArray< T >::PushBack ( const T &  iValue = T())
inline

PushBack, insert a new element at the end of the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ PushBack() [2/2]

template<typename T>
void TArray< T >::PushBack ( T &&  iValue)
inline

PushBack, insert a new element at the end of the buffer, possibly reallocating the underlying storage if the capacity has been reached.

◆ Reserve()

template<typename T>
void TArray< T >::Reserve ( uint64  iCapacity)
inline

Reserve some capacity for future usage, if iCapacity is bigger than the current capacity.

If iCapacity is lower or equal to capacity, this function does nothing.

This function might invalid existing pointers to the underlying buffer.

The size doesn't change.

◆ Resize()

template<typename T>
void TArray< T >::Resize ( uint64  iSize)
inline

Resize the actual usage size of the container. This function might invalid the underlying buffer when requesting a bigger size. It has no effect if the requested size is the same as the current size.

◆ Shrink()

template<typename T>
void TArray< T >::Shrink ( )
inline

Shrink the capacity to fit the size. If the capacity is already the same as the size, the function does nothing. This function might invalid the underlying buffer. The size doesn't change.

◆ Size()

template<typename T>
uint64 TArray< T >::Size ( ) const
inline

Returns the array size.