數據結構與算法(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 wont be empty for ever
}
public override bool IsLeaf()
{
return this.degree==0;//if this trees 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;
}
}
}