// Shows how we can manually build a tree. static string MakeStringTree(int iSpaces) { string[] arr_sLetters = { "P", "M", "X", "D", "E", "F", "G", "H", "J", "K" }; Stack <string> stk_sLetters = new Stack <string>(); CStringTreeNode stnRoot, stnChild, stnGrandChild; foreach (string sLetter in arr_sLetters) { stk_sLetters.Push(sLetter); } // Visual Studio complains but we can actually just leave the childless nodes unasigned. stnRoot = new CStringTreeNode(stk_sLetters.Pop()); stnChild = new CStringTreeNode(stk_sLetters.Pop(), stnRoot, CTreeNode.ENodeCreate.ENODE_FIRST_CHILD); new CStringTreeNode(stk_sLetters.Pop(), stnChild, CTreeNode.ENodeCreate.ENODE_FIRST_CHILD); new CStringTreeNode(stk_sLetters.Pop(), stnChild, CTreeNode.ENodeCreate.ENODE_LAST_CHILD); stnChild = new CStringTreeNode(stk_sLetters.Pop(), stnRoot, CTreeNode.ENodeCreate.ENODE_LAST_CHILD); stnGrandChild = new CStringTreeNode(stk_sLetters.Pop(), stnChild, CTreeNode.ENodeCreate.ENODE_FIRST_CHILD); new CStringTreeNode(stk_sLetters.Pop(), stnGrandChild, CTreeNode.ENodeCreate.ENODE_FIRST_CHILD); stnGrandChild = new CStringTreeNode(stk_sLetters.Pop(), stnChild, CTreeNode.ENodeCreate.ENODE_LAST_CHILD); new CStringTreeNode(stk_sLetters.Pop(), stnGrandChild, CTreeNode.ENodeCreate.ENODE_FIRST_CHILD); new CStringTreeNode(stk_sLetters.Pop(), stnGrandChild, CTreeNode.ENodeCreate.ENODE_LAST_CHILD); return(stnRoot.WriteTreeToString(iSpaces)); }
public CStringTreeNode(string sStr, CStringTreeNode pNode, ENodeCreate eFlag) : base(pNode, eFlag) { m_sStr = sStr; }