You are here: Symbol Reference > MtxExpr Namespace > Classes > Vector Record > public > Vector.Scatter Method
MtxVec VCL
ContentsIndex
PreviousUpNext
Vector.Scatter Method

Scatter object elements.

Pascal
function Scatter(const Src: TMtxVec; const Indexes: TVecInt = nil; IndexType: TIndexType = indVector; Increment: integer = 1; Offset: integer = 0): TMtxVec; overload;

Scatter the elements of the Src and store them in the calling object according to the IndexType, Increment and Offset parameters. 

The Indexes vector is used only if IndexType is either indVector or indMask. If IndexType is indVector, the values from the Indexes object denote the Index positions in the calling object to which the values should be copied from the Src. The Indexes vector must have the indexes stored in the IValues array. The IValues integer arrays points the same memory as Values array. 

The Increment and Offset parameters are used only if TIndexType is indIncrement. They define the target offset and a fixed step (increment) between calling vector elements. 

If IndexType is indMaks the Indexes object must have the same size as the Src object. The routine will copy only those elements from the Src to the calling object, for which there is a 1 at the coresponding Index in the Indexes object.The elements in the calling object are stored consecutively. 

See the Gather method to see how to perform gathering. 

The performance of the CPU heavily depends on the assumption that elements are stored at consecutive memory locations. If it is neccessary to apply a set of operations only to elements at specific indexes, performance-wise it can prove to be very helpfull, if the elements are gathered first.

Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!