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

The TLimitedArray class provides a simple dynamic array or vector class for ULIS interfaces, with a maximum capacity or limit. More...

Public Member Functions

 TLimitedArray ()
 
 TLimitedArray (const TLimitedArray< T, _LIMIT > &iOther)=delete
 
 TLimitedArray (TLimitedArray< T, _LIMIT > &&iOther) noexcept
 
 TLimitedArray (uint64 iSize)
 
 ~TLimitedArray ()
 
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
 
uint64 Limit () const
 
TLimitedArray< T, _LIMIT > & operator= (const TLimitedArray< T, _LIMIT > &iOther)=delete
 
TLimitedArray< T, _LIMIT > & operator= (TLimitedArray< T, _LIMIT > &&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, uint64 _LIMIT>
class TLimitedArray< T, _LIMIT >

The need of a custom TLimitedArray 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

◆ ~TLimitedArray()

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >::~TLimitedArray ( )
inline

Destroy the Array and cleanup memory.

◆ TLimitedArray() [1/4]

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >::TLimitedArray ( )
inline

Default constructor with size 0, capicity 0, uninitialized.

◆ TLimitedArray() [2/4]

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >::TLimitedArray ( 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.

◆ TLimitedArray() [3/4]

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >::TLimitedArray ( const TLimitedArray< T, _LIMIT > &  iOther)
delete

Copy constructor, explicitly removed.

◆ TLimitedArray() [4/4]

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >::TLimitedArray ( TLimitedArray< T, _LIMIT > &&  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 , uint64 _LIMIT>
T& TLimitedArray< T, _LIMIT >::At ( uint64  iIndex)
inline

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

See also
operator[]()

◆ At() [2/2]

template<typename T , uint64 _LIMIT>
const T& TLimitedArray< T, _LIMIT >::At ( uint64  iIndex) const
inline

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

See also
operator[]() const

◆ Back() [1/2]

template<typename T , uint64 _LIMIT>
T& TLimitedArray< T, _LIMIT >::Back ( )
inline

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

◆ Back() [2/2]

template<typename T , uint64 _LIMIT>
const T& TLimitedArray< T, _LIMIT >::Back ( ) const
inline

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

◆ Bits() [1/2]

template<typename T , uint64 _LIMIT>
uint8* TLimitedArray< T, _LIMIT >::Bits ( )
inline

Returns the raw bits.

◆ Bits() [2/2]

template<typename T , uint64 _LIMIT>
const uint8* TLimitedArray< T, _LIMIT >::Bits ( ) const
inline

Returns the const raw bits.

◆ Capacity()

template<typename T , uint64 _LIMIT>
uint64 TLimitedArray< T, _LIMIT >::Capacity ( ) const
inline

Returns the array capacity.

◆ Clear()

template<typename T , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::Clear ( )
inline

Clear the array, deallocating everything.

◆ Data() [1/2]

template<typename T , uint64 _LIMIT>
T* TLimitedArray< T, _LIMIT >::Data ( )
inline

Returns the storage.

◆ Data() [2/2]

template<typename T , uint64 _LIMIT>
const T* TLimitedArray< T, _LIMIT >::Data ( ) const
inline

Returns the const storage.

◆ Emplace()

template<typename T , uint64 _LIMIT>
template<class ... Args>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
template<class ... Args>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
T& TLimitedArray< T, _LIMIT >::Front ( )
inline

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

◆ Front() [2/2]

template<typename T , uint64 _LIMIT>
const T& TLimitedArray< T, _LIMIT >::Front ( ) const
inline

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

◆ Insert() [1/3]

template<typename T , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
bool TLimitedArray< T, _LIMIT >::IsEmpty ( ) const
inline

Returns wether the array is empty or not.

◆ Limit()

template<typename T , uint64 _LIMIT>
uint64 TLimitedArray< T, _LIMIT >::Limit ( ) const
inline

Returns the array limit.

◆ operator=() [1/2]

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >& TLimitedArray< T, _LIMIT >::operator= ( const TLimitedArray< T, _LIMIT > &  iOther)
delete

Copy Assignment Operator, explicitly removed.

◆ operator=() [2/2]

template<typename T , uint64 _LIMIT>
TLimitedArray< T, _LIMIT >& TLimitedArray< T, _LIMIT >::operator= ( TLimitedArray< T, _LIMIT > &&  iOther)
delete

Move Assignment Operator, explicitly removed.

◆ operator[]() [1/2]

template<typename T , uint64 _LIMIT>
T& TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
const T& TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::PopBack ( )
inline

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

◆ PushBack() [1/2]

template<typename T , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 , uint64 _LIMIT>
void TLimitedArray< T, _LIMIT >::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 _LIMIT>
uint64 TLimitedArray< T, _LIMIT >::Size ( ) const
inline

Returns the array size.