2.1.6.14 convert_tree_double_vector_to_str_vector


Description

Convert double vector treenode to string vector.

Syntax

int convert_tree_double_vector_to_str_vector( const TreeNode & trVec, vector<string> & vs, uint nSize, string strFmt = "*" )


int convert_tree_double_vector_to_str_vector( const TreeNode & trVec, vector<string> & vs, const vector<int> & vnSignDigites = NULL )

Parameters

trVec
[input]source vector treenode to convert.
vs
[output]string vector for the result
nSize
[input]vs's size, if nSize > trVec.dVals.GetSize(), vs will size of trvec size.
strFmt
[input]format of convert double value, default is "*", mean show as system default setting, "*2" mean sets to display two significant digits.
vnSignDigites
[input] set each node double value convert significant digits.

Return

Returns the -1 when trVec not double vector. else return the size of vs.

Examples

EX1

void test_convert_tree_double_vector_to_str_vector_ex1()
{
    Tree tr;
    vector    vd = {1,2,3,4.0989};
    tr.tr1.dVals = vd;
    vector<string> vs;
    int nRet = convert_tree_double_vector_to_str_vector(tr.tr1, vs, vd.GetSize(),"*3");    
    for(int nIndex =0 ; nIndex < vs.GetSize(); nIndex++)
        out_str(vs[nIndex]);//output 1.00, 2.00, 3.00, 4.10
}


EX2

void test_convert_tree_double_vector_to_str_vector_ex2()
{
    Tree tr;
    vector    vd = {1,2,3,4.0989};
    vector<int>    vsd = {1,2,3,4};
    tr.tr1.dVals = vd;
    vector<string> vs;
    int nRet = convert_tree_double_vector_to_str_vector(tr.tr1, vs, vsd);    
    for(int nIndex =0 ; nIndex < vs.GetSize(); nIndex++)
        out_str(vs[nIndex]);//output 1, 2.0, 3.00, 4.099
}

Remark

See Also

Header to Include

origin.h

Reference