VectorInt.Resize Method

Overload List

#SignatureDescription
1function Resize(const Src: TVecInt; const Len: Integer; const ZeroIt: Boolean): TVecInt;Resizes vector size while preserving values.
2function Resize(const Len: Integer; const ZeroIt: Boolean): TVecInt;Resizes calling vector Length to Len.

Overload 1: function Resize(const Src: TVecInt; const Len: Integer; const ZeroIt: Boolean): TVecInt;

Resizes vector size while preserving values.

#NameTypeDescription
1SrcTVecInt
2LenIntegerelement count
3ZeroItBoolean

Result: stored in self (calling object), returns self for chaining

Remarks:

Resizes calling vector TMtxVecBase.Length to Len and fills it with Src vector first Len values. If Src length is less than Len and ZeroIt parameter is true, the remaining calling vector values are set to zero.

Examples
var a, b: TVecInt;
begin
    CreateIt(a,b);
    try
        a.SetIt([1,2,3]);
        b.SetIt([9]);
        b.Resize(a,7,True); // b=(9,1,2,3,4,0,0,0)
    finally
        FreeIt(a,b);
    end;
end;

Overload 2: function Resize(const Len: Integer; const ZeroIt: Boolean): TVecInt;

Resizes calling vector Length to Len.

#NameTypeDescription
1LenIntegerelement count
2ZeroItBoolean

Result: stored in self (calling object), returns self for chaining

Remarks:

If VectorInt.Length is less than Len and ZeroIt parameter is true, the remaining calling vector values are set to zero.

Examples
var a: TVecInt;
begin
    CreateIt(a);
    try
        a.SetIt([1,2,3]);
        a.Resize(7,True); // a= [1,2,3,0,0,0,0]
    finally
        FreeIt(a);
    end;
end;