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
}
}