2.1.26.72 tree_update_changes


Description

Walk tree and store attribute "OldValue" into all the nodes that has different value from the specified string. The vs array can be obtained by tree_get_values.

Syntax

int tree_update_changes( TreeNode & tr, const vector<string> & vs )

Parameters

tr
[Input]TreeNode to walk
vs
[Input]a linearized array of string values that should map to every tree node

Return

Total number of nodes that has OldValue attributes added (changed)

Examples

EX1

void tree_update_changes_ex1()
{
    Tree tr;
    TreeNode trFirst = tr.AddNode("First");
    trFirst.SetAttribute(STR_CHANGED_ATTRIB, "Changed");
    TreeNode trSecond = tr.AddNode("Second");
    trSecond.SetAttribute(STR_CHANGED_ATTRIB, "Changed");

    vector<string> vs={"First", "Second"};
    int nCount = tree_update_changes(tr, vs);
    printf("%d nodes changed:\n", nCount);
    string strLabel;
    foreach(TreeNode trNode in tr.Children)
    {
        trNode.GetAttribute(STR_CHANGED_ATTRIB, strLabel);
        out_str(strLabel);
    }
}

Remark

See Also

Header to Include

origin.h

Reference