﻿ 數據結構與算法_電腦知識網

# 數據結構與算法

2013-11-13 10:24:55  來源: .NET編程

廣義樹和基本樹的主要區別就是有任意的度

usingSystem;

usingSystemCollections;

namespaceDataStructure{

///<summary>

///GeneralTree的摘要說明

///generaltreeisatreewhichhasaarbitrarydegreeandnoemptytree

///</summary>

publicclassGeneralTree:Tree　　{

protectedobjectkey=null;　　　　protecteduintdegree=;

//protecteduintheight=;

protectedArrayListtreeList=newArrayList();

publicGeneralTree(object_objKey)　　　　{

//

//TODO:在此處添加構造函數邏輯

//

key=_objKey;

degree=;

//

height=;

ArrayListtreeList=newArrayList();

}

publicvirtualvoidAttackSubtree(GeneralTree_gTree)　　　　{

++degree;

}

publicvirtualGeneralTreeDetachSubtree(GeneralTree_gTree)　　　　{

thistreeListRemove(_gTree);

degree;

return_gTree;

//?????　howtoremovereferenceorobject????

}

publicoverrideTreethis[uint_index]

{

get

{

if(_index>=thisdegree)

thrownewException(my:outofindex);

return(Tree)treeList[(int)_index];

}

set

{

treeList[(int)_index]=value;

}

}

From:http://tw.wingwit.com/Article/program/net/201311/13543.html