數(shù)據(jù)結(jié)構(gòu)與算法(C#完成)系列---廣義樹(二)
發(fā)表時間:2024-05-18 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]數(shù)據(jù)結(jié)構(gòu)與算法(C#實現(xiàn))系列---廣義樹(二)Heavenkiller(原創(chuàng)) public override object Keygetreturn this.key; public override uint Degreegetreturn this.d...
數(shù)據(jù)結(jié)構(gòu)與算法(C#實現(xiàn))系列---廣義樹(二)
Heavenkiller(原創(chuàng))
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 won't be empty for ever
}
public override bool IsLeaf()
{
return this.degree==0;//if this tree's 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類型,故轉(zhuǎn)型不會失敗
GeneralTree tmpTree=(GeneralTree)_obj;
//比較引用成員
if( !Object.Equals(this.treeList,tmpTree.treeList) )
return false;
//比較值類型成員
return true;
}
}
}