VectorInt.Ramp Method

Overload List

#SignatureDescription
1function Ramp: TVecInt;Fills the calling vector with a series following linear rule.
2function Ramp(const Offset: Double; const Step: Double): TVecInt;Fills the calling vector.
└ indexed: function Ramp(const Offset: Double; const Step: Double; const Index: Integer; const Len: Integer): TVecInt;

Overload 1: function Ramp: TVecInt;

Fills the calling vector with a series following linear rule.

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

Remarks:

Fills the calling vector with a series following the rule:

Values[k] :=  k

(Offset is zero and Step is one).

Examples
var a: TVecInt;
begin
    CreateIt(a);
    try
        a.Size(5,int32);
        a.Ramp(0,2); // [0, 2, 4, 6, 8]
    finally
        FreeIt(a);
    end;
end;
CreateIt(a);
try
    a.Size(5,int32);
    for i:= 0 to a.Length-1 do a[i] := i*2;
finally
    FreeIt(a);
end;
See Also: VectorInt.SetVal

Overload 2: function Ramp(const Offset: Double; const Step: Double): TVecInt;

Fills the calling vector.

#NameTypeDescription
1OffsetDouble
2StepDouble

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

Remarks:

Method uses the following rule:

Values[k] := Offset + k*Step.
Examples
Values[k] :=  k

Indexed: function Ramp(const Offset: Double; const Step: Double; const Index: Integer; const Len: Integer): TVecInt;

Fills the calling vector elements [Index]..[Index+Len-1].

#NameTypeDescription
1OffsetDouble
2StepDouble
3IndexIntegerstart index
4LenIntegerelement count

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

Remarks:

Method uses the following rule:

Values[k] := Offset + k*Step.

An exception is raised if calling vector array borders are overrun.

Examples
Values[k] := Offset + k*Step.