Data structures and algorithms (C # implementation) series --- tree (III)

Source: Internet
Author: User

Data structures and algorithms (C # implementation) series --- tree (III)

Heavenkiller (original)

 

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

Public override bool Equals (object _ obj)

{

If (_ obj = null)

Return false; // this cannot be null

If (! (This. GetType () = _ obj. GetType ()))

Return false; // The type is not equal.

Tree tmpObj = (Tree) _ obj;

// Compare referenced members

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

Return false;

// Compare value type members

If (! This. Degree. Equals (tmpObj. Degree ))

Return false;

// If (! This. Height. Equals (tmpObj. Height ))

// Return false;

 

Return true;

}

// Reload here = ,! =, It is not necessary to implement

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 Member

 

Public virtual int CompareTo (object obj)

{

// TODO: Add Tree. CompareTo implementation

Return 0;

}

 

# Endregion

}

}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.