廣義樹和基本樹的主要區別就是有任意的度
usingSystem;
usingSystem
namespaceDataStructure{
///<summary>
///GeneralTree的摘要說明
///generaltreeisatreewhichhasaarbitrarydegreeandnoemptytree
///useArrayListtoreplaceListAsLinkedList
///</summary>
publicclassGeneralTree:Tree {
protectedobjectkey=null; protecteduintdegree=
//protecteduintheight=
protectedArrayListtreeList=newArrayList();
publicGeneralTree(object_objKey) {
//
//TODO:在此處添加構造函數邏輯
//
key=_objKey;
degree=
//
height=
ArrayListtreeList=newArrayList();
}
publicvirtualvoidAttackSubtree(GeneralTree_gTree) {
this
++degree;
}
publicvirtualGeneralTreeDetachSubtree(GeneralTree_gTree) {
this
degree
return_gTree;
//????? howtoremove
}
publicoverrideTreethis[uint_index]
{
get
{
if(_index>=this
thrownewException(
return(Tree)treeList[(int)_index];
}
set
{
treeList[(int)_index]=value;
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13543.html