2.1.17.8.1 find_largest_gap


Description

get the index of largest gap from value array, array must be sorted first

Syntax

int find_largest_gap( const vector & vValue )

Parameters

vValue
[input] sorted value array

Return

index of largest gap, return -1 if size of array less than 2.

Examples

EX1

void find_large_gap_ex1()
{
    vector vSorted = {0, 20, 50, 100, 300, 330};
    int nIndex = find_largest_gap(vSorted);
    ASSERT(3 == nIndex);
}

EX2

void find_large_gap_ex2()
{
    vector vv = {-100, 30, -80, -50, 90};
    vv.Sort();
    int nIndex = find_largest_gap(vv);
    ASSERT(2 == nIndex);
}

Remark

See Also

Header to Include

origin.h

Reference