2.1.26.26 tree_copy_values_by_id


Description

Walk all nodes, look for nodes with ID, and apply it to destination tree nodes that has same ID

Syntax

int tree_copy_values_by_id( const TreeNode & trSrc, TreeNode & trDest )

Parameters

trSrc
[input]a source tree node
trDest
[modify]destination tree node

Return

number of nodes that the values are copied or 0 if none.

Examples

EX1

void tree_copy_values_by_id_ex1()
{
	Tree trSrc;
	Tree trDes;
	
	trSrc.China.SetAttribute(STR_DATAID_ATTRIB,1);
	trSrc.China.strVal = "Asia";
	trSrc.France.SetAttribute(STR_DATAID_ATTRIB,2);
	trSrc.France.strVal = "Europe";
	trSrc.Egypt.SetAttribute(STR_DATAID_ATTRIB,3);
	trSrc.Egypt.strVal = "Africa";
	
	trDes.India.SetAttribute(STR_DATAID_ATTRIB,1);
	trDes.England.SetAttribute(STR_DATAID_ATTRIB,2);
	trDes.Congo.SetAttribute(STR_DATAID_ATTRIB,3);
	
	int nRet = tree_copy_values_by_id(trSrc , trDes);
	out_int("nRet = ", nRet);
	out_str(trDes.India.strVal);
	out_str(trDes.England.strVal);
	out_str(trDes.Congo.strVal);
}

Remark

See Also

tree_copy_values

Header to Include

origin.h

Reference