数据结构与算法(C#实现)系列---广义树(二)
发布时间:2006-10-14 3:12:52   收集提供:gaoqian

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

         }

     }

}

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50