您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200602
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

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

sinory

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

 Heavenkiller(原创)

 

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

         public override bool Equals(object _obj)

         {

              if( _obj==null )

                   return false;//因为this不可能为null

              if( ! (this.GetType()==_obj.GetType()) )

                   return false;//类型不相等也不相等

              Tree tmpObj=(Tree)_obj;

              //比较引用成员

              if( !Object.Equals(this.Key,tmpObj.Key) )

                   return false;

             

              //比较值类型成员

              if( !this.Degree.Equals(tmpObj.Degree) )

                   return false;

              //if( !this.Height.Equals(tmpObj.Height) )

                   //return false;

 

              return true;

         }

         //在此重载 ==,!= 后, 在以后继承的类中不必实现了

         public static bool operator==(Tree _treeA,Tree _treeB)

         {

              return Object.Equals(_treeA,_treeB);

         }

         public static bool operator!=(Tree _treeA,Tree _treeB)

         {

              return !(_treeA==_treeB);

         }

        

 

    

 

    

    

         #region IComparable 成员

 

         public virtual int CompareTo(object obj)

         {

              // TODO:  添加 Tree.CompareTo 实现

              return 0;

         }

 

         #endregion

    

     }

}

 转自:www.sinory.com