Data Structure and Algorithm (C # Implementation) Series --- Tree (3)
HEAVENKILLER (original)
// OverWrite Object.equals () --- Reference Type Realization
Public Override Bool Equals (Object_Obj)
{
IF (_obj == null)
Return false; // Because this is not possible for null
IF (! (this.gettype () == _ Obj.gettype ())))
Return False; // Type is not equal, no equal
Tree tmpobj = (tre) _obj;
// Compare reference 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;
}
// This is overloaded ==, after! =, It does not have to be implemented in the class inherited later.
Public Static Bool Operator == (Tree_treea, Tree_treeb)
{
Return Object.equals (_treea, _treeb);
}
Public Static Bool Operator! = (Tree_treea, Tree_treeb)
{
Return! (_ tree == _ treec);
}
#Region iComparable member
Public Virtual Int Compato (Object Obj)
{
// Todo: Add Tree.Compareto implementation
Return 0;
}
#ndregion
}
}