Open CASCADE Technology  7.7.0
Public Member Functions | Protected Attributes
NCollection_AliasedArray< MyAlignSize > Class Template Reference

Defines an array of values of configurable size. For instance, this class allows defining an array of 32-bit or 64-bit integer values with bitness determined in runtime. The element size in bytes (stride) should be specified at construction time. Indexation starts from 0 index. As actual type of element varies at runtime, element accessors are defined as templates. Memory for array is allocated with the given alignment (template parameter). More...

#include <NCollection_AliasedArray.hxx>

Public Member Functions

 NCollection_AliasedArray (Standard_Integer theStride)
 Empty constructor. More...
 
 NCollection_AliasedArray (Standard_Integer theStride, Standard_Integer theLength)
 Constructor. More...
 
 NCollection_AliasedArray (const NCollection_AliasedArray &theOther)
 Copy constructor. More...
 
 NCollection_AliasedArray (NCollection_AliasedArray &&theOther) Standard_Noexcept
 Move constructor. More...
 
template<typename Type_t >
 NCollection_AliasedArray (const Type_t &theBegin, Standard_Integer theLength)
 Constructor wrapping pre-allocated C-array of values without copying them. More...
 
Standard_Integer Stride () const
 Returns an element size in bytes. More...
 
Standard_Integer Size () const
 Size query. More...
 
Standard_Integer Length () const
 Length query (the same as Size()) More...
 
Standard_Boolean IsEmpty () const
 Return TRUE if array has zero length. More...
 
Standard_Integer Lower () const
 Lower bound. More...
 
Standard_Integer Upper () const
 Upper bound. More...
 
Standard_Boolean IsDeletable () const
 myDeletable flag More...
 
Standard_Boolean IsAllocated () const
 IsAllocated flag - for naming compatibility. More...
 
Standard_Size SizeBytes () const
 Return buffer size in bytes. More...
 
NCollection_AliasedArrayAssign (const NCollection_AliasedArray &theOther)
 Copies data of theOther array to this. This array should be pre-allocated and have the same length as theOther; otherwise exception Standard_DimensionMismatch is thrown. More...
 
NCollection_AliasedArrayMove (NCollection_AliasedArray &theOther)
 Move assignment. This array will borrow all the data from theOther. The moved object will keep pointer to the memory buffer and range, but it will not free the buffer on destruction. More...
 
NCollection_AliasedArrayoperator= (const NCollection_AliasedArray &theOther)
 Assignment operator;. More...
 
NCollection_AliasedArrayoperator= (NCollection_AliasedArray &&theOther)
 Move assignment operator;. More...
 
void Resize (Standard_Integer theLength, Standard_Boolean theToCopyData)
 Resizes the array to specified bounds. No re-allocation will be done if length of array does not change, but existing values will not be discarded if theToCopyData set to FALSE. More...
 
 ~NCollection_AliasedArray ()
 Destructor - releases the memory. More...
 
const Standard_Bytevalue (Standard_Integer theIndex) const
 Access raw bytes of specified element. More...
 
Standard_BytechangeValue (Standard_Integer theIndex)
 Access raw bytes of specified element. More...
 
template<typename Type_t >
void Init (const Type_t &theValue)
 Initialize the items with theValue. More...
 
template<typename Type_t >
const Type_t & Value (Standard_Integer theIndex) const
 Access element with specified position and type. This method requires size of a type matching stride value. More...
 
template<typename Type_t >
void Value (Standard_Integer theIndex, Type_t &theValue) const
 Access element with specified position and type. This method requires size of a type matching stride value. More...
 
template<typename Type_t >
Type_t & ChangeValue (Standard_Integer theIndex)
 Access element with specified position and type. This method requires size of a type matching stride value. More...
 
template<typename Type_t >
const Type_t & Value2 (Standard_Integer theIndex) const
 Access element with specified position and type. This method allows wrapping element into smaller type (e.g. to alias 2-components within 3-component vector). More...
 
template<typename Type_t >
void Value2 (Standard_Integer theIndex, Type_t &theValue) const
 Access element with specified position and type. This method allows wrapping element into smaller type (e.g. to alias 2-components within 3-component vector). More...
 
template<typename Type_t >
Type_t & ChangeValue2 (Standard_Integer theIndex)
 Access element with specified position and type. This method allows wrapping element into smaller type (e.g. to alias 2-components within 3-component vector). More...
 
template<typename Type_t >
const Type_t & First () const
 Return first element. More...
 
template<typename Type_t >
Type_t & ChangeFirst ()
 Return first element. More...
 
template<typename Type_t >
const Type_t & Last () const
 Return last element. More...
 
template<typename Type_t >
Type_t & ChangeLast ()
 Return last element. More...
 

Protected Attributes

Standard_BytemyData
 data pointer More...
 
Standard_Integer myStride
 element size More...
 
Standard_Integer mySize
 number of elements More...
 
Standard_Boolean myDeletable
 flag showing who allocated the array More...
 

Detailed Description

template<int MyAlignSize = 16>
class NCollection_AliasedArray< MyAlignSize >

Defines an array of values of configurable size. For instance, this class allows defining an array of 32-bit or 64-bit integer values with bitness determined in runtime. The element size in bytes (stride) should be specified at construction time. Indexation starts from 0 index. As actual type of element varies at runtime, element accessors are defined as templates. Memory for array is allocated with the given alignment (template parameter).

Constructor & Destructor Documentation

◆ NCollection_AliasedArray() [1/5]

template<int MyAlignSize = 16>
NCollection_AliasedArray< MyAlignSize >::NCollection_AliasedArray ( Standard_Integer  theStride)
inline

Empty constructor.

◆ NCollection_AliasedArray() [2/5]

template<int MyAlignSize = 16>
NCollection_AliasedArray< MyAlignSize >::NCollection_AliasedArray ( Standard_Integer  theStride,
Standard_Integer  theLength 
)
inline

Constructor.

◆ NCollection_AliasedArray() [3/5]

template<int MyAlignSize = 16>
NCollection_AliasedArray< MyAlignSize >::NCollection_AliasedArray ( const NCollection_AliasedArray< MyAlignSize > &  theOther)
inline

Copy constructor.

◆ NCollection_AliasedArray() [4/5]

template<int MyAlignSize = 16>
NCollection_AliasedArray< MyAlignSize >::NCollection_AliasedArray ( NCollection_AliasedArray< MyAlignSize > &&  theOther)
inline

Move constructor.

◆ NCollection_AliasedArray() [5/5]

template<int MyAlignSize = 16>
template<typename Type_t >
NCollection_AliasedArray< MyAlignSize >::NCollection_AliasedArray ( const Type_t &  theBegin,
Standard_Integer  theLength 
)
inline

Constructor wrapping pre-allocated C-array of values without copying them.

◆ ~NCollection_AliasedArray()

template<int MyAlignSize = 16>
NCollection_AliasedArray< MyAlignSize >::~NCollection_AliasedArray ( )
inline

Destructor - releases the memory.

Member Function Documentation

◆ Assign()

template<int MyAlignSize = 16>
NCollection_AliasedArray& NCollection_AliasedArray< MyAlignSize >::Assign ( const NCollection_AliasedArray< MyAlignSize > &  theOther)
inline

Copies data of theOther array to this. This array should be pre-allocated and have the same length as theOther; otherwise exception Standard_DimensionMismatch is thrown.

◆ ChangeFirst()

template<int MyAlignSize = 16>
template<typename Type_t >
Type_t& NCollection_AliasedArray< MyAlignSize >::ChangeFirst ( )
inline

Return first element.

◆ ChangeLast()

template<int MyAlignSize = 16>
template<typename Type_t >
Type_t& NCollection_AliasedArray< MyAlignSize >::ChangeLast ( )
inline

Return last element.

◆ changeValue()

template<int MyAlignSize = 16>
Standard_Byte* NCollection_AliasedArray< MyAlignSize >::changeValue ( Standard_Integer  theIndex)
inline

Access raw bytes of specified element.

◆ ChangeValue()

template<int MyAlignSize = 16>
template<typename Type_t >
Type_t& NCollection_AliasedArray< MyAlignSize >::ChangeValue ( Standard_Integer  theIndex)
inline

Access element with specified position and type. This method requires size of a type matching stride value.

◆ ChangeValue2()

template<int MyAlignSize = 16>
template<typename Type_t >
Type_t& NCollection_AliasedArray< MyAlignSize >::ChangeValue2 ( Standard_Integer  theIndex)
inline

Access element with specified position and type. This method allows wrapping element into smaller type (e.g. to alias 2-components within 3-component vector).

◆ First()

template<int MyAlignSize = 16>
template<typename Type_t >
const Type_t& NCollection_AliasedArray< MyAlignSize >::First ( ) const
inline

Return first element.

◆ Init()

template<int MyAlignSize = 16>
template<typename Type_t >
void NCollection_AliasedArray< MyAlignSize >::Init ( const Type_t &  theValue)
inline

Initialize the items with theValue.

◆ IsAllocated()

template<int MyAlignSize = 16>
Standard_Boolean NCollection_AliasedArray< MyAlignSize >::IsAllocated ( ) const
inline

IsAllocated flag - for naming compatibility.

◆ IsDeletable()

template<int MyAlignSize = 16>
Standard_Boolean NCollection_AliasedArray< MyAlignSize >::IsDeletable ( ) const
inline

myDeletable flag

◆ IsEmpty()

template<int MyAlignSize = 16>
Standard_Boolean NCollection_AliasedArray< MyAlignSize >::IsEmpty ( ) const
inline

Return TRUE if array has zero length.

◆ Last()

template<int MyAlignSize = 16>
template<typename Type_t >
const Type_t& NCollection_AliasedArray< MyAlignSize >::Last ( ) const
inline

Return last element.

◆ Length()

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::Length ( ) const
inline

Length query (the same as Size())

◆ Lower()

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::Lower ( ) const
inline

Lower bound.

◆ Move()

template<int MyAlignSize = 16>
NCollection_AliasedArray& NCollection_AliasedArray< MyAlignSize >::Move ( NCollection_AliasedArray< MyAlignSize > &  theOther)
inline

Move assignment. This array will borrow all the data from theOther. The moved object will keep pointer to the memory buffer and range, but it will not free the buffer on destruction.

◆ operator=() [1/2]

template<int MyAlignSize = 16>
NCollection_AliasedArray& NCollection_AliasedArray< MyAlignSize >::operator= ( const NCollection_AliasedArray< MyAlignSize > &  theOther)
inline

Assignment operator;.

See also
Assign()

◆ operator=() [2/2]

template<int MyAlignSize = 16>
NCollection_AliasedArray& NCollection_AliasedArray< MyAlignSize >::operator= ( NCollection_AliasedArray< MyAlignSize > &&  theOther)
inline

Move assignment operator;.

See also
Move()

◆ Resize()

template<int MyAlignSize = 16>
void NCollection_AliasedArray< MyAlignSize >::Resize ( Standard_Integer  theLength,
Standard_Boolean  theToCopyData 
)
inline

Resizes the array to specified bounds. No re-allocation will be done if length of array does not change, but existing values will not be discarded if theToCopyData set to FALSE.

Parameters
theLengthnew length of array
theToCopyDataflag to copy existing data into new array

◆ Size()

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::Size ( ) const
inline

Size query.

◆ SizeBytes()

template<int MyAlignSize = 16>
Standard_Size NCollection_AliasedArray< MyAlignSize >::SizeBytes ( ) const
inline

Return buffer size in bytes.

◆ Stride()

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::Stride ( ) const
inline

Returns an element size in bytes.

◆ Upper()

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::Upper ( ) const
inline

Upper bound.

◆ value()

template<int MyAlignSize = 16>
const Standard_Byte* NCollection_AliasedArray< MyAlignSize >::value ( Standard_Integer  theIndex) const
inline

Access raw bytes of specified element.

◆ Value() [1/2]

template<int MyAlignSize = 16>
template<typename Type_t >
const Type_t& NCollection_AliasedArray< MyAlignSize >::Value ( Standard_Integer  theIndex) const
inline

Access element with specified position and type. This method requires size of a type matching stride value.

◆ Value() [2/2]

template<int MyAlignSize = 16>
template<typename Type_t >
void NCollection_AliasedArray< MyAlignSize >::Value ( Standard_Integer  theIndex,
Type_t &  theValue 
) const
inline

Access element with specified position and type. This method requires size of a type matching stride value.

◆ Value2() [1/2]

template<int MyAlignSize = 16>
template<typename Type_t >
const Type_t& NCollection_AliasedArray< MyAlignSize >::Value2 ( Standard_Integer  theIndex) const
inline

Access element with specified position and type. This method allows wrapping element into smaller type (e.g. to alias 2-components within 3-component vector).

◆ Value2() [2/2]

template<int MyAlignSize = 16>
template<typename Type_t >
void NCollection_AliasedArray< MyAlignSize >::Value2 ( Standard_Integer  theIndex,
Type_t &  theValue 
) const
inline

Access element with specified position and type. This method allows wrapping element into smaller type (e.g. to alias 2-components within 3-component vector).

Field Documentation

◆ myData

template<int MyAlignSize = 16>
Standard_Byte* NCollection_AliasedArray< MyAlignSize >::myData
protected

data pointer

◆ myDeletable

template<int MyAlignSize = 16>
Standard_Boolean NCollection_AliasedArray< MyAlignSize >::myDeletable
protected

flag showing who allocated the array

◆ mySize

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::mySize
protected

number of elements

◆ myStride

template<int MyAlignSize = 16>
Standard_Integer NCollection_AliasedArray< MyAlignSize >::myStride
protected

element size


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