2.2.3.19.6 vectorbase::Difference

Description

Get difference between successive elements of the vector

Syntax

BOOL Difference( vectorbase& vecDiff )

Parameters

vecDiff
[output] will contain the differences of the source vector. The length of vecDiff will be n-1, where n is the length of the source vector.

Return

Returns TRUE on success and FALSE on error.

Examples

EX1

void vectorbase_Difference_ex1()
{
    // Declare data vector and fill with some data
    vector<int> vecData = {23, 12, 7, 28};
    
    // Declare vector to hold differences and call method
    vector<int> vecDiff;
    BOOL bRet = vecData.Difference(vecDiff);
    
    if( !bRet ) 
        out_str("Failed to computed difference vector");
    else
    {
        for (int i = 0; i < vecDiff.GetSize(); i++ )
                printf("%d ", vecDiff[i]);
    }
    // On success, result should be:
    //    vecDiff = -11 -5 21
}

Remark

Get the difference between successive elements of a vector.

See Also

Header to Include

origin.h