2.2.3.2.7 CategoricalMap::ReverseLookUp

Description

Reverse look up an index in this CategoricalMap and return its category.

Syntax

string ReverseLookUp( int iVal )

Parameters

iVal
[input]Input index(1-offset) value to reverse look up

Return

Returns the category or text value in this CategoricalMap referred to by the index if found, or returns an empty string if it is not found.

Examples

EX1

void CategoricalMap_ReverseLookUp_ex1()
{
    Worksheet wks;
    wks.Create();
    if (wks)
    { 
        Dataset    ds(wks, 0);
        ds.SetSize(8);
        vector<string> vs = {"aaa","bbb","ddd","ccc","qqq","777","aaa","ddd"};
        ds.PutStringArray(vs);

        string strWksColname = wks.Columns(0).GetName();
        strWksColname = wks.GetPage().GetName() + "_" + strWksColname;
        
        StringArray vMyCatMap;
        CategoricalData cdMyCatData(strWksColname);
        vMyCatMap = (StringArray) cdMyCatData.Map;
        int index = cdMyCatData.Map.LookUp("ddd");
        string strVal = cdMyCatData.Map.ReverseLookUp(5);//strVal="qqq"
    }
}

Remark

Reverse look up an index (1 based offset) in this CategoricalMap and return its category (or text value). If the CategoricalMap has an associated CategoricalData data set the mapped index values in the CategoricalData data set refer to the text values in this CategoricalMap. For EX1, the index 5 refers to the text value "qqq".

See Also

CategoricalMap::LookUp

Header to Include

origin.h