首页 | ASP | HTML | ASP.NET | PHP | JSP | C#/CSHARP | SQL | XML | SMS | 网站制作 | 会员登录 | 会员投稿
 当前位置:首页>>C#/CSHARP>>c#教程>>正文
数据结构与算法(C#实现)系列---广义树(一)
文章出处:   发布时间:2005-08-17
 

数据结构与算法(C#实现)系列---广义树(一)

Heavenkiller(原创)

广义树和基本树的主要区别就是有任意的度

using System;
using System.Collections;
namespace DataStructure

{
     /// <summary>

     /// GeneralTree 的摘要说明。

     /// general tree is a tree which has a arbitrary degree and no empty tree

     /// use ArrayList to replace ListAsLinkedList

     /// </summary>

     public class GeneralTree:Tree

     {

         protected object key=null;

         protected uint degree=0;

         //protected uint height=0;

 

         protected ArrayList treeList=new ArrayList();

 

         public GeneralTree(object _objKey)

         {

              //

              // TODO: 在此处添加构造函数逻辑

              //

 

              key=_objKey;

              degree=0;

         //   height=0;

              ArrayList treeList=new ArrayList();

         }

 

         public virtual void AttackSubtree(GeneralTree _gTree)

         {

              this.treeList.Add(_gTree);

              ++degree;

         }

         public virtual GeneralTree DetachSubtree(GeneralTree _gTree)

         {

             

              this.treeList.Remove(_gTree);

              degree--;

             

              return _gTree;//?????  how to remove ,reference or object????

         }

 

         public override Tree this[uint _index]

         {

              get

              {

                   if(_index>=this.degree)

                       throw new Exception("my:out of index");

                   return (Tree)treeList[(int)_index];

              }

              set

              {
                   treeList[(int)_index]=value;

              }
         }


[返回顶部↑]  [推荐好友] [查看评论]  
用户名: 新注册) 密码: 匿名评论 [查看评论]  发表评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 
↑文章搜索
  关键字:  
  范  围:  
  搜索功能暂未开放  
※相关文章※
 

◎数据结构与算法(C#实现)系
◎数据结构与算法(C#实现)系
◎数据结构与算法(C#实现)系
◎数据结构与算法(C#实现)系
◎数据结构与算法(C#实现)系
◎数据结构与算法(C#实现)系
◎数据结构与算法(C#实现)系

 
※热点文章※
  ·数据结构与算法(C#实现)系
·数据结构与算法(C#实现)系
·C#中的代理(delegate)
·C#中的数组和C++中数组
·C#中的“装箱”(boxing)
·C#中的checked、unchecke
·switch语句的“不准遍历”