Tree is a common data structure, and traversal is the most common access mode.
. Net. If generics are used, the following method will be more generic. This document does not use generics.
/// <Summary>
/// Delegate-process subnodes
/// </Summary>
1) Public Delegate void dealwith (string Str );
/// <Summary>
/// Delegate-obtain the subnode
/// </Summary>
2) Public Delegate string [] getchilds (string Str );
/// <Summary>
/// Recursive access To the tree data structure
/// </Summary>
/// <Param name = "root"> node to be accessed </param>
/// <Param name = "GCS"> </param>
/// <Param name = "DW"> </param>
3) Public static void getallchilds (string root, getchilds GCS, dealwith DW)
{
DW (Root );
String [] child = GCS (Root );
For (INT I = 0; I <child. length; I ++)
{
Getallchilds (child [I], GCS, DW );
}
}
1) Processing of accessed nodes, such as display or filling in the list
2) It mainly indicates a delegate for obtaining its lower-level nodes. Here it is a delegate that returns a String Array
3) The main function used to traverse nodes.