VectorInt::SetSubRange Method

Overload List

#SignatureDescription
1void SetSubRange(const int Index, const int Len) const;Defines a sub vector/matrix.
2void SetSubRange(TMtxVecInt *Src) const;Defines the calling vector to have the view of the same memory as Src.
3void SetSubRange(TMtxVecInt *Src, const int Index, const int Len = MtxVecEOA) const;Define a subvector of the Src vector.
4void SetSubRange() const;Sets the subarray size to full size.

Overload 1: void SetSubRange(const int Index, const int Len) const;

Defines a sub vector/matrix.

#NameTypeDescription
1Indexconst int
2Lenconst int
Remarks:

The method will define a subarray starting at Index and ending at Index+Len-1. No copying will occur, only pointers will be shifted.

All values of the original Vector will be preserved. An exception will be raised if an attempt is made to change the size of calling object.

A sub-vector/matrix is vector/matrix which does not neccessarily have its own memory allocated. Instead it adopts the memory of the source object and all operations done on the either of the objects affect the same elements. The use of subvectors/submatrices increases CPU cache reuse, lower's memory requirements, increases application performance and improves code readability.

Note
To again obtain a view of the full vector/matrix, see VectorInt::SetFullRange

Declared in Dew::Math::VectorInt · Dew.Math/MtxExprInt.h · Cross-compiler

Overload 2: void SetSubRange(TMtxVecInt *Src) const;

Defines the calling vector to have the view of the same memory as Src.

#NameTypeDescription
1SrcTMtxVecInt *
Remarks:

Src vector's Length property may not change while any other object has it's own view of it.

a.SetSubRange(b,..);

This SetSubRange method must be handled with great care. Namely:

  • b can be freed before "a" and accessing "a" gives AV.
  • a can be further subranged with c and same problem occurs when b is freed before c.
  • If you resize b, all objects which have subranged b are no longer pointing to valid memory.
  • b can Subrange other objects. Similar problem as when changing the size of b. Again all objects which have subranged b are not longer pointing to valid memory.

All this can lead to hard to find bugs. It is therefore recommended to contstrain the use of the Subrange within the scope of one routine.

See Also: VectorInt::SetSubRange, VectorInt::SetFullRange
Declared in Dew::Math::VectorInt · Dew.Math/MtxExprInt.h · Cross-compiler

Overload 3: void SetSubRange(TMtxVecInt *Src, const int Index, const int Len = MtxVecEOA) const;

Define a subvector of the Src vector.

#NameTypeDescription
1SrcTMtxVecInt *
2Indexconst int
3Len = MtxVecEOAconst int
Remarks:

The method will define a subarray starting at Index and ending at Index+Len-1 of Src. No copying will occur, only pointers will be shifted or indices adjusted.

A sub-vector/matrix is vector/matrix which does not neccessarily have its own memory allocated. Instead it adopts the memory of the source object and all operations done on the either of the objects affect the same elements. The use of subvectors/submatrices increases CPU cache reuse, lower's memory requirements, increases application performance and improves code readability.

All values of the original TMtxVecBase will be preserved. An exception will be raised, if an attempt is made to change the size of calling object. No exception will be raised, if Src is resized while subranged. (possibly leading to memory overwrites)

To again obtain a view of the original vector/matrix, call VectorInt::SetFullRange

Declared in Dew::Math::VectorInt · Dew.Math/MtxExprInt.h · Cross-compiler

Overload 4: void SetSubRange() const;

Sets the subarray size to full size.

Remarks:

This method is the same as the VectorInt::SetFullRange method.

Declared in Dew::Math::VectorInt · Dew.Math/MtxExprInt.h · Cross-compiler