麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

數據結構與算法(C#實現)系列---N叉樹(二)

2019-11-18 19:43:12
字體:
來源:轉載
供稿:網友

數據結構與算法(C#實現)系列---N叉樹(二)

Heavenkiller(原創)

public override uint Degree

         {

              get

              {

                   return this.degree;

              }

         }
                     

         //只用于空樹結點

         public virtual void AttachKey(object _obj)

         {

              if(!IsEmpty())

                   throw new Exception("My:this node must be a empty tree node!");

              this.key=_obj;

              this.treeList=new ArrayList();//產生一個degree長的數組,并將其初始化為空樹

              this.treeList.Capacity=(int)this.degree;

 

              for(int i=0;i<this.degree;i++)

              {

                   treeList.Add(new NaryTree(this.degree));

              }

              /*

              foreach(object tmpObj in this.treeList)

              {

                   tmpObj=new NaryTree(this.degree);

              }

              */

         }

         //只用于葉子結點,將葉子結點變為一個空結點,并返回葉子結點關鍵字的引用

         public virtual object DetachKey()

         {

              if(!IsLeaf())

                   throw new Exception("My:this node must be a leaf node!");

              object result=this.key;//store this leaf node temporary

              this.key=null;

              this.treeList=null;

 

              return result;

         }

         //將子樹連接到指定樹的第num個結點上,前提是這個結點必須是空結點,并且度數相同,否則拋出異常

         public virtual void AttachSubtree(uint num,NaryTree _naryTree)

         {

              if(this.IsEmpty())

                   throw new Exception("My:it can't be a empty tree!");

              if(!(this[num-1].IsEmpty()) | this.degree!=_naryTree.degree )

                   throw new Exception("My:this[i-1] must be empty and they should have the same degree!");

              this[num-1]=_naryTree;

         }

         //僅為非空樹定義,從給定樹中刪去它的第i棵子樹并連上一個空樹,度數相同,并且返回刪除的子樹引用

         public virtual NaryTree DetachSubtree(uint num)

         {

              if (IsEmpty())

                   throw new Exception("My:it can't be empty! ");

              NaryTree tmpTree=this;

              ((NaryTree)this[num-1]).key=null;

              ((NaryTree)this[num-1]).treeList=null;

 

              return this;

         }

     }

}

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产精品毛片无码 | 永久免费黄色大片 | 精品国产91久久久久久 | 国产午夜精品一区二区三区免费 | 日本va在线观看 | 久久精品视频日本 | 密室逃脱第一季免费观看完整在线 | 欧美日在线观看 | 亚洲成人在线免费 | 色阁五月 | 亚洲性视频 | 亚洲一区在线视频观看 | 九九热视频在线免费观看 | 国产亚洲精品久久久久久网站 | 黄色av免费电影 | 久久国产精品99国产 | 久草在线视频精品 | 久久精品男人 | 精品国产一区二区三区四 | 一区在线免费视频 | 国产好片无限资源 | 日本视频免费观看 | 一二区成人影院电影网 | 欧美一级黄色片在线观看 | 欧美日韩在线视频一区 | 精品在线免费播放 | 国产精品性夜天天视频 | 久草欧美 | 欧美另类视频在线 | 99国产精品欲a | 成人爽a毛片免费啪啪红桃视频 | 男人天堂新地址 | 91精品国产日韩91久久久久久360 | 亚洲性在线视频 | 黄色网址进入 | 欧美视频一级 | 成人午夜视频网站 | 毛片免费视频播放 | 日韩欧美高清片 | 成年人视频免费 | av中文一区 |