数据结构与算法(C#实现)系列---N叉树(二)

作者:凯旋网络来源:凯旋网络

数据结构与算法(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())

              

  • 广告推荐