public override UINT Degree
{
Get
{
return this.degree;
}
}
For empty tree nodes only.
public virtual void Attachkey (object _obj)
{
if (! IsEmpty ())
throw new Exception ("My:this node must being a empty tree node!");
This.key=_obj;
This.treelist=new ArrayList ()//generates a degree long array and initializes it to an empty tree
this.treelist.capacity= (int) this.degree;
for (int i=0;i<this.degree;i++)
{
Treelist.add (New Narytree (This.degree));
}
/*
foreach (Object tmpobj in This.treelist)
{
Tmpobj=new Narytree (This.degree);
}
*/
}
Used only for leaf nodes, turning leaf nodes into an empty node, and returning the reference to the leaf node key word
Public virtual Object Detachkey ()
{
if (! IsLeaf ())
throw new Exception ("My:this node must be a leaf node!");
Object Result=this.key;//store This leaf node temporary
This.key=null;
This.treelist=null;
return result;
}
Connects the subtree to the NUM node of the specified tree, provided that the node must be an empty node and has the same degree, otherwise throwing an exception
public virtual void Attachsubtree (UINT num,narytree _narytree)
{
if (this. IsEmpty ())
throw new Exception ("My:it can ' t be a empty tree!");
if (!) ( THIS[NUM-1]. IsEmpty ()) | This.degree!=_narytree.degree)
throw new Exception ("my:this[i-1] must be empty and they should have the same");
This[num-1]=_narytree;
}
Defines only a non-empty tree, deletes its Shang tree from a given tree and connects an empty tree with the same degree, and returns the subtree reference that was deleted
Public virtual Narytree detachsubtree (uint num)
{
if (IsEmpty ())
throw new Exception ("My:it can ' t be empty!");
Narytree Tmptree=this;
((Narytree) this[num-1]). Key=null;
((Narytree) this[num-1]). Treelist=null;
return this;
}
}
}