Raytrix Light Field SDK  4.0
Logo
Public Member Functions | Protected Attributes | List of all members
Rx::CRxArray< TValue > Class Template Referenceabstract

Detailed Description

template<typename TValue>
class Rx::CRxArray< TValue >

Generic array class.

Template Parameters
TValueGeneric type parameter.

Inherits Rx::Interop::Runtime30::IMemory.

Public Member Functions

 CRxArray ()
 Default constructor. Creates an empty array. More...
 
 CRxArray (size_t nElementCount)
 Constructor. Creates a new array with the given number of default-constructed elements. More...
 
 CRxArray (size_t nElementCount, const TValue &tInitValue)
 Constructor. Constructs a new array with nElementCount copies of elements with value tInitValue. More...
 
 CRxArray (const CRxArray< TValue > &xArray)
 Copy constructor. Creates a copy of the given array. More...
 
 CRxArray (CRxArray< TValue > &&xArray)
 Move constructor. More...
 
 CRxArray (void *pvInternal, bool bMove)
 Creates a new array by moving or copying the internal data into this array. More...
 
virtual ~CRxArray ()
 Destructs the array. More...
 
void Assign (size_t nElementCount, const TValue &tInitValue)
 Replaces the contents with nElementCount copies of value tInitValue. More...
 
TValue & At (size_t nIndex)
 Returns a reference to the element at the specified index, with bounds checking. If nIndex is not within the range of the array, an exception is thrown. More...
 
const TValue & At (size_t nIndex) const
 Returns a reference to the element at the specified index, with bounds checking. If nIndex is not within the range of the array, an exception is thrown. More...
 
TValue & Back ()
 Returns a reference to the last element in the array. Calling Back on an empty array is undefined. More...
 
const TValue & Back () const
 Returns a reference to the last element in the array. Calling Back on an empty array is undefined. More...
 
TValue * begin ()
 Returns an iterator (pointer) to the first element of the array. More...
 
const TValue * begin () const
 Returns an iterator (pointer) to the first element of the array. More...
 
size_t Capacity () const
 Returns the number of elements that the array has currently allocated space for. More...
 
void Clear ()
 Removes all elements from the array. More...
 
virtual void CopyFrom (const IMemoryAccess *pMemory)=0
 Copies the memory block described by pMemory into this memory block. This memory block is automatically resized. The function throws an exception if the element sizes of the given memory block does not agree with the element size of this memory block. More...
 
virtual void CopyFrom (const IMemoryAccess *pxSrcMemory)
 Copies the content of the given source memory into this array. Sets the size of this array to the size of the memory. More...
 
void CopyFromInternal (const void *pvInternal)
 Creates a new array by copying the internal data into this array. More...
 
void CopyIntoInternal (void *pvInternal) const
 Copies this array into the internal data. More...
 
TValue * Data ()
 Gets the pointer to the internal data. More...
 
const TValue * Data () const
 Gets the pointer to the internal data. More...
 
virtual void Delete ()
 Removes all elements from the array. More...
 
TValue * end ()
 Returns an iterator (pointer) to the element following the last element of the array. This element acts as a placeholder; attempting to access it results in undefined behavior. More...
 
const TValue * end () const
 Returns an iterator (pointer) to the element following the last element of the array. This element acts as a placeholder; attempting to access it results in undefined behavior. More...
 
void Erase (size_t nPosition)
 Removes the element at the given position from the array. More...
 
void Erase (size_t nPosition, size_t nCount)
 Removes specified elements from the array. More...
 
TValue & Front ()
 Returns a reference to the first element in the array. Calling Front on an empty array is undefined. More...
 
const TValue & Front () const
 Returns a reference to the first element in the array. Calling Front on an empty array is undefined. More...
 
virtual size_t GetElementSize () const
 Gets the size of a single value in this array. More...
 
virtual void * GetPointer ()
 Gets the pointer to the internal data. More...
 
virtual const void * GetPointer () const
 Gets the pointer to the internal data. More...
 
void Insert (size_t nPosition, const TValue &tValue)
 Inserts elements at the specified location in the array. More...
 
void Insert (size_t nPosition, TValue &&tValue)
 Inserts elements at the specified location in the array. More...
 
void Insert (size_t nPosition, size_t nCount, const TValue &tValue)
 Inserts nCount copies of tValue at the specified location in the array. More...
 
bool IsEmpty () const
 Checks if the array has no elements. More...
 
virtual bool IsValid () const
 Query if this object is valid. Returns always true. More...
 
virtual size_t Length () const
 Gets the number of elements in this array. More...
 
void MoveFromInternal (void *pvInternal)
 Creates a new array by moving the internal data into this array. More...
 
void MoveIntoInternal (void *pvInternal)
 moves this array into the internal data. This array is empty afterwards. More...
 
virtual void New (size_t nElementCount)
 Resizes the array to contain count elements. More...
 
CRxArray< TValue > & operator= (const CRxArray< TValue > &xArray)
 Copy assignment operator. Replaces the contents with a copy of the contents of the given array. More...
 
CRxArray< TValue > & operator= (CRxArray< TValue > &&xArray)
 Move assignment operator. Replaces the contents with those of the given array using move semantics (i.e. the data in the given array is moved into this array). The given array is in a valid but unspecified state afterwards. More...
 
TValue & operator[] (size_t nIndex)
 Returns a reference to the element at the specified index. No bounds checking is performed. More...
 
const TValue & operator[] (size_t nIndex) const
 Returns a reference to the element at the specified index. No bounds checking is performed. More...
 
void PopBack ()
 Removes the last element of the array. Calling PopBack on an empty array is undefined. More...
 
void PushBack (const TValue &tValue)
 Appends the given element value to the end of the array. The new element is initialized as a copy of tValue. More...
 
void PushBack (TValue &&tValue)
 Appends the given element value to the end of the array. The value is moved into the new element. More...
 
void Reserve (size_t nNewElementCount)
 Increase the capacity of the array to a value that's greater or equal to nNewElementCount. If nNewElementCount is greater than the current capacity, new storage is allocated, otherwise the method does nothing. More...
 
virtual void Reset ()
 Sets the internal memory to zeros. More...
 
void Resize (size_t nNewElementCount, const TValue &tValue)
 Resizes the array to contain count elements. More...
 
virtual void Resize (size_t nNewElementCount)
 Resizes the array to contain count elements. More...
 
void ShrinkToFit ()
 Requests the removal of unused capacity. More...
 
size_t Size () const
 Returns the number of elements in the array. More...
 
void Swap (CRxArray< TValue > &xArray)
 Exchanges the contents of the array with those of xArray. Does not invoke any move, copy, or swap operations on individual elements. More...
 

Protected Attributes

void * m_pvVector
 

Constructor & Destructor Documentation

template<typename TValue>
Rx::CRxArray< TValue >::CRxArray ( )

Default constructor. Creates an empty array.

template<typename TValue>
Rx::CRxArray< TValue >::CRxArray ( size_t  nElementCount)

Constructor. Creates a new array with the given number of default-constructed elements.

Parameters
nElementCountThe number of elements.
template<typename TValue>
Rx::CRxArray< TValue >::CRxArray ( size_t  nElementCount,
const TValue &  tInitValue 
)

Constructor. Constructs a new array with nElementCount copies of elements with value tInitValue.

Parameters
nElementCountThe number of elements.
tInitValueThe initial value of each element in this array.
template<typename TValue>
Rx::CRxArray< TValue >::CRxArray ( const CRxArray< TValue > &  xArray)

Copy constructor. Creates a copy of the given array.

Parameters
xArrayThe array to copy.
template<typename TValue>
Rx::CRxArray< TValue >::CRxArray ( CRxArray< TValue > &&  xArray)

Move constructor.

Parameters
xArray[in,out] The array to move.
template<typename TValue>
Rx::CRxArray< TValue >::CRxArray ( void *  pvInternal,
bool  bMove 
)

Creates a new array by moving or copying the internal data into this array.

Parameters
pvInternal[in,out] Pointer to the internal data.
bMoveTrue to move the data, false to copy the data.
template<typename TValue>
virtual Rx::CRxArray< TValue >::~CRxArray ( )
virtual

Destructs the array.

The destructor of the elements are called and the used storage is deallocated. Note, that if the elements are pointers, the pointed-to objects are not destroyed.

Member Function Documentation

template<typename TValue>
void Rx::CRxArray< TValue >::Assign ( size_t  nElementCount,
const TValue &  tInitValue 
)

Replaces the contents with nElementCount copies of value tInitValue.

template<typename TValue>
TValue& Rx::CRxArray< TValue >::At ( size_t  nIndex)

Returns a reference to the element at the specified index, with bounds checking. If nIndex is not within the range of the array, an exception is thrown.

Parameters
nIndexThe index.
Returns
Reference to the requested element.
template<typename TValue>
const TValue& Rx::CRxArray< TValue >::At ( size_t  nIndex) const

Returns a reference to the element at the specified index, with bounds checking. If nIndex is not within the range of the array, an exception is thrown.

Parameters
nIndexThe index.
Returns
Reference to the requested element.
template<typename TValue>
TValue& Rx::CRxArray< TValue >::Back ( )

Returns a reference to the last element in the array. Calling Back on an empty array is undefined.

Returns
Reference to the last element.
template<typename TValue>
const TValue& Rx::CRxArray< TValue >::Back ( ) const

Returns a reference to the last element in the array. Calling Back on an empty array is undefined.

Returns
Reference to the last element.
template<typename TValue>
TValue* Rx::CRxArray< TValue >::begin ( )

Returns an iterator (pointer) to the first element of the array.

Returns
Iterator to the first element.
template<typename TValue>
const TValue* Rx::CRxArray< TValue >::begin ( ) const

Returns an iterator (pointer) to the first element of the array.

Returns
Iterator to the first element.
template<typename TValue>
size_t Rx::CRxArray< TValue >::Capacity ( ) const

Returns the number of elements that the array has currently allocated space for.

Returns
Capacity of the currently allocated storage.
template<typename TValue>
void Rx::CRxArray< TValue >::Clear ( )

Removes all elements from the array.

Invalidates any references, pointers, or iterators referring to contained elements. Any past-the-end iterators are also invalidated.

Leaves the Capacity() of the array unchanged.

virtual void Rx::Interop::Runtime30::IMemory::CopyFrom ( const IMemoryAccess pMemory)
pure virtualinherited

Copies the memory block described by pMemory into this memory block. This memory block is automatically resized. The function throws an exception if the element sizes of the given memory block does not agree with the element size of this memory block.

Parameters
pMemory[in] The memory to copy into this memory block.
template<typename TValue>
virtual void Rx::CRxArray< TValue >::CopyFrom ( const IMemoryAccess *  pxSrcMemory)
virtual

Copies the content of the given source memory into this array. Sets the size of this array to the size of the memory.

Parameters
pxSrcMemoryThe source memory.
template<typename TValue>
void Rx::CRxArray< TValue >::CopyFromInternal ( const void *  pvInternal)

Creates a new array by copying the internal data into this array.

Parameters
pvInternal[in,out] Pointer to the internal data.
template<typename TValue>
void Rx::CRxArray< TValue >::CopyIntoInternal ( void *  pvInternal) const

Copies this array into the internal data.

Parameters
pvInternal[in,out] Pointer to the internal data.
template<typename TValue>
TValue* Rx::CRxArray< TValue >::Data ( )

Gets the pointer to the internal data.

Returns
The pointer.
template<typename TValue>
const TValue* Rx::CRxArray< TValue >::Data ( ) const

Gets the pointer to the internal data.

Returns
The pointer.
template<typename TValue>
virtual void Rx::CRxArray< TValue >::Delete ( )
virtual

Removes all elements from the array.

Invalidates any references, pointers, or iterators referring to contained elements. Any past-the-end iterators are also invalidated.

Leaves the Capacity() of the array unchanged.

Implements Rx::Interop::Runtime30::IMemory.

template<typename TValue>
TValue* Rx::CRxArray< TValue >::end ( )

Returns an iterator (pointer) to the element following the last element of the array. This element acts as a placeholder; attempting to access it results in undefined behavior.

Returns
Iterator to the element following the last element.
template<typename TValue>
const TValue* Rx::CRxArray< TValue >::end ( ) const

Returns an iterator (pointer) to the element following the last element of the array. This element acts as a placeholder; attempting to access it results in undefined behavior.

Returns
Iterator to the element following the last element.
template<typename TValue>
void Rx::CRxArray< TValue >::Erase ( size_t  nPosition)

Removes the element at the given position from the array.

Parameters
nPositionThe position.
template<typename TValue>
void Rx::CRxArray< TValue >::Erase ( size_t  nPosition,
size_t  nCount 
)

Removes specified elements from the array.

Parameters
nPositionThe position.
nCountNumber of elements to remove.
template<typename TValue>
TValue& Rx::CRxArray< TValue >::Front ( )

Returns a reference to the first element in the array. Calling Front on an empty array is undefined.

Returns
Reference to the first element.
template<typename TValue>
const TValue& Rx::CRxArray< TValue >::Front ( ) const

Returns a reference to the first element in the array. Calling Front on an empty array is undefined.

Returns
Reference to the first element.
template<typename TValue>
virtual size_t Rx::CRxArray< TValue >::GetElementSize ( ) const
virtual

Gets the size of a single value in this array.

Returns
The element size.

Implements Rx::Interop::Runtime30::IMemoryAccess.

template<typename TValue>
virtual void* Rx::CRxArray< TValue >::GetPointer ( )
virtual

Gets the pointer to the internal data.

Returns
The pointer.

Implements Rx::Interop::Runtime30::IMemory.

template<typename TValue>
virtual const void* Rx::CRxArray< TValue >::GetPointer ( ) const
virtual

Gets the pointer to the internal data.

Returns
The pointer.

Implements Rx::Interop::Runtime30::IMemoryAccess.

template<typename TValue>
void Rx::CRxArray< TValue >::Insert ( size_t  nPosition,
const TValue &  tValue 
)

Inserts elements at the specified location in the array.

Causes reallocation if the new size is greater than the old capacity. If the new size is greater than capacity, all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Parameters
nPositionThe position.
tValueThe value.
template<typename TValue>
void Rx::CRxArray< TValue >::Insert ( size_t  nPosition,
TValue &&  tValue 
)

Inserts elements at the specified location in the array.

Causes reallocation if the new size is greater than the old capacity. If the new size is greater than capacity, all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Parameters
nPositionThe position.
tValue[in,out] The value to move.
template<typename TValue>
void Rx::CRxArray< TValue >::Insert ( size_t  nPosition,
size_t  nCount,
const TValue &  tValue 
)

Inserts nCount copies of tValue at the specified location in the array.

Causes reallocation if the new size is greater than the old capacity. If the new size is greater than capacity, all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Parameters
nPositionThe position.
tValueThe value.
template<typename TValue>
bool Rx::CRxArray< TValue >::IsEmpty ( ) const

Checks if the array has no elements.

Returns
True if the array is empty, false otherwise.
template<typename TValue>
virtual bool Rx::CRxArray< TValue >::IsValid ( ) const
virtual

Query if this object is valid. Returns always true.

Returns
True if valid, false if not.

Implements Rx::Interop::Runtime30::IMemoryAccess.

template<typename TValue>
virtual size_t Rx::CRxArray< TValue >::Length ( ) const
virtual

Gets the number of elements in this array.

Returns
The length.

Implements Rx::Interop::Runtime30::IMemoryAccess.

template<typename TValue>
void Rx::CRxArray< TValue >::MoveFromInternal ( void *  pvInternal)

Creates a new array by moving the internal data into this array.

Parameters
pvInternal[in,out] Pointer to the internal data.
template<typename TValue>
void Rx::CRxArray< TValue >::MoveIntoInternal ( void *  pvInternal)

moves this array into the internal data. This array is empty afterwards.

Parameters
pvInternal[in,out] Pointer to the internal data.
template<typename TValue>
virtual void Rx::CRxArray< TValue >::New ( size_t  nElementCount)
virtual

Resizes the array to contain count elements.

If the current size is greater than nNewElementCount, the array is reduced to its first nNewElementCount elements.

If the current size is less than count, additional default-inserted elements are appended.

Parameters
nNewElementCountNumber of new elements.

Implements Rx::Interop::Runtime30::IMemory.

template<typename TValue>
CRxArray<TValue>& Rx::CRxArray< TValue >::operator= ( const CRxArray< TValue > &  xArray)

Copy assignment operator. Replaces the contents with a copy of the contents of the given array.

Parameters
xArrayThe array to copy.
Returns
This array.
template<typename TValue>
CRxArray<TValue>& Rx::CRxArray< TValue >::operator= ( CRxArray< TValue > &&  xArray)

Move assignment operator. Replaces the contents with those of the given array using move semantics (i.e. the data in the given array is moved into this array). The given array is in a valid but unspecified state afterwards.

Parameters
xArray[in,out] The array to move.
Returns
This array.
template<typename TValue>
TValue& Rx::CRxArray< TValue >::operator[] ( size_t  nIndex)

Returns a reference to the element at the specified index. No bounds checking is performed.

Parameters
nIndexThe index.
Returns
Reference to the requested element.
template<typename TValue>
const TValue& Rx::CRxArray< TValue >::operator[] ( size_t  nIndex) const

Returns a reference to the element at the specified index. No bounds checking is performed.

Parameters
nIndexThe index.
Returns
Reference to the requested element.
template<typename TValue>
void Rx::CRxArray< TValue >::PopBack ( )

Removes the last element of the array. Calling PopBack on an empty array is undefined.

template<typename TValue>
void Rx::CRxArray< TValue >::PushBack ( const TValue &  tValue)

Appends the given element value to the end of the array. The new element is initialized as a copy of tValue.

If the new size is greater than capacity then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.

Parameters
tValueThe value of the element to append.
template<typename TValue>
void Rx::CRxArray< TValue >::PushBack ( TValue &&  tValue)

Appends the given element value to the end of the array. The value is moved into the new element.

If the new size is greater than capacity then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.

Parameters
tValue[in,out] The value of the element to append.
template<typename TValue>
void Rx::CRxArray< TValue >::Reserve ( size_t  nNewElementCount)

Increase the capacity of the array to a value that's greater or equal to nNewElementCount. If nNewElementCount is greater than the current capacity, new storage is allocated, otherwise the method does nothing.

If nNewElementCount is greater than capacity, all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.

Reserve cannot be used to reduce the capacity of the array, to that end ShrinkToFit() is provided.

Correctly using Reserve can prevent unnecessary reallocations, but inappropriate uses of Reserve (for instance, calling it before every PushBack() call) may actually increase the number of reallocations (by causing the capacity to grow linearly rather than exponentially) and result in increased computational complexity and decreased performance.

Parameters
nNewElementCountThe new element count.
template<typename TValue>
virtual void Rx::CRxArray< TValue >::Reset ( )
virtual

Sets the internal memory to zeros.

Implements Rx::Interop::Runtime30::IMemory.

template<typename TValue>
void Rx::CRxArray< TValue >::Resize ( size_t  nNewElementCount,
const TValue &  tValue 
)

Resizes the array to contain count elements.

If the current size is greater than nNewElementCount, the array is reduced to its first nNewElementCount elements.

If the current size is less than count, additional copies of tValue are appended.

Parameters
nNewElementCountNew size of the array.
tValueThe value to initialize the new elements with.
template<typename TValue>
virtual void Rx::CRxArray< TValue >::Resize ( size_t  nNewElementCount)
virtual

Resizes the array to contain count elements.

If the current size is greater than nNewElementCount, the array is reduced to its first nNewElementCount elements.

If the current size is less than count, additional default-inserted elements are appended.

Parameters
nNewElementCountNumber of new elements.

Implements Rx::Interop::Runtime30::IMemory.

template<typename TValue>
void Rx::CRxArray< TValue >::ShrinkToFit ( )

Requests the removal of unused capacity.

It is a non-binding request to reduce Capacity() to Size(). It depends on the implementation if the request is fulfilled.

If reallocation occurs, all iterators, including the past the end iterator, and all references to the elements are invalidated. If no reallocation takes place, no iterators or references are invalidated.

template<typename TValue>
size_t Rx::CRxArray< TValue >::Size ( ) const

Returns the number of elements in the array.

Returns
The number of elements in the array.
template<typename TValue>
void Rx::CRxArray< TValue >::Swap ( CRxArray< TValue > &  xArray)

Exchanges the contents of the array with those of xArray. Does not invoke any move, copy, or swap operations on individual elements.

Parameters
xArray[in,out] The array to exchange the contents with.

Member Data Documentation

template<typename TValue>
void* Rx::CRxArray< TValue >::m_pvVector
protected