明辉站/网站教程/内容

数据结构与算法(C#完成)系列---广义树(二)

网站教程2024-05-16 阅读
[摘要]数据结构与算法(C#实现)系列---广义树(二)Heavenkiller(原创) public override object Keygetreturn this.key; public override uint Degreegetreturn this.d...

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

Heavenkiller(原创)

 

         public  override object Key{get{return this.key;}}

         public  override uint Degree{get{return this.degree;}}

         //public  override uint Height{get{return this.height;}}

 

         public  override bool IsEmpty()// property takes the place of IsEmpty()

         {
              return false;//generaltree won't be empty for ever
         }    
         public  override bool IsLeaf()
         {
              return this.degree==0;//if this tree's degree is zero, it means the tree has no subtrees, so it is leaf certainly

         }

         //overwrite Object.Equals() ---  reference  type   realization

         public override bool Equals(object _obj)

         {

              if( !base.Equals(_obj) )

                   return false;//基类比较不相等,则不相等

              //基类中的一些条目在此可免去

              //在基类中已判定其为GeneralTree类型,故转型不会失败

              GeneralTree tmpTree=(GeneralTree)_obj;

              //比较引用成员

              if( !Object.Equals(this.treeList,tmpTree.treeList) )

                   return false;     

              //比较值类型成员

              return true;

         }

     }

}

……

相关阅读