Open CASCADE Technology 7.8.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>

Inheritance diagram for NCollection_AliasedArray< MyAlignSize >:
Inheritance graph
[legend]

Public Member Functions

 NCollection_AliasedArray (Standard_Integer theStride)
 Empty constructor.
 
 NCollection_AliasedArray (Standard_Integer theStride, Standard_Integer theLength)
 Constructor.
 
 NCollection_AliasedArray (const NCollection_AliasedArray &theOther)
 Copy constructor.
 
 NCollection_AliasedArray (NCollection_AliasedArray &&theOther) Standard_Noexcept
 Move constructor.
 
template<typename Type_t >
 NCollection_AliasedArray (const Type_t &theBegin, Standard_Integer theLength)
 Constructor wrapping pre-allocated C-array of values without copying them.
 
Standard_Integer Stride () const
 Returns an element size in bytes.
 
Standard_Integer Size () const
 Size query.
 
Standard_Integer Length () const
 Length query (the same as Size())
 
Standard_Boolean IsEmpty () const
 Return TRUE if array has zero length.
 
Standard_Integer Lower () const
 Lower bound.
 
Standard_Integer Upper () const
 Upper bound.
 
Standard_Boolean IsDeletable () const
 myDeletable flag
 
Standard_Boolean IsAllocated () const
 IsAllocated flag - for naming compatibility.
 
Standard_Size SizeBytes () const
 Return buffer size in bytes.
 
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.
 
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.
 
NCollection_AliasedArrayoperator= (const NCollection_AliasedArray &theOther)
 Assignment operator;.
 
NCollection_AliasedArrayoperator= (NCollection_AliasedArray &&theOther)
 Move assignment operator;.
 
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.
 
 ~NCollection_AliasedArray ()
 Destructor - releases the memory.
 
const Standard_Bytevalue (Standard_Integer theIndex) const
 Access raw bytes of specified element.
 
Standard_BytechangeValue (Standard_Integer theIndex)
 Access raw bytes of specified element.
 
template<typename Type_t >
void Init (const Type_t &theValue)
 Initialize the items with theValue.
 
template<typename Type_t >
const Type_tValue (Standard_Integer theIndex) const
 Access element with specified position and type. This method requires size of a type matching stride value.
 
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.
 
template<typename Type_t >
Type_tChangeValue (Standard_Integer theIndex)
 Access element with specified position and type. This method requires size of a type matching stride value.
 
template<typename Type_t >
const Type_tValue2 (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).
 
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).
 
template<typename Type_t >
Type_tChangeValue2 (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).
 
template<typename Type_t >
const Type_tFirst () const
 Return first element.
 
template<typename Type_t >
Type_tChangeFirst ()
 Return first element.
 
template<typename Type_t >
const Type_tLast () const
 Return last element.
 
template<typename Type_t >
Type_tChangeLast ()
 Return last element.
 

Protected Attributes

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

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]

Copy constructor.

◆ NCollection_AliasedArray() [4/5]

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]

Assignment operator;.

See also
Assign()

◆ operator=() [2/2]

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: