网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C#教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.C#和VB.net语法对比图.
.SUNWEN教程之----C#进阶(九).
.C#基础概念二十五问.
.请教如何改善C#中socket通信机客.
.数据结构与算法(C#实现)系列---广.
.c#里面的namespace基础(二).
.C#语言初级入门(4).
.SUNWEN教程之----C#进阶(一).
.C#的四个基本技巧 .
.SUNWEN教程之----C#进阶(六).
.SUNWEN教程之----C#进阶(五).
.C#的多线程机制初探(1) .
.C# 3.0新特性初步研究 Part4:使用.
.C# 中的类型转换.
.C#中的数组和C++中数组的区别.
.Excel 2007单元格及内容的合并、.
.C# 3.0新特性体验之Lambda表达式.
.关于C#的问答.
.C#的多线程机制初探(4).
.一个用c#写的扫描asp源码漏洞的应.

数据结构与算法(C#实现)系列---N叉树(二)

发表日期:2004-2-7


数据结构与算法(C#实现)系列---N叉树(二)

Heavenkiller(原创)

public override uint Degree

         {

              get

              {

                   return this.degree;

              }

         }
                     

         //只用于空树结点

         public virtual void AttachKey(object _obj)

         {

              if(!IsEmpty())

                   throw new Exception("My:this node must be a empty tree node!");

              this.key=_obj;

              this.treeList=new ArrayList();//产生一个degree长的数组,并将其初始化为空树

              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);

              }

              */

         }

         //只用于叶子结点,将叶子结点变为一个空结点,并返回叶子结点关键字的引用

         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;

         }

         //将子树连接到指定树的第num个结点上,前提是这个结点必须是空结点,并且度数相同,否则抛出异常

         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 degree!");

              this[num-1]=_naryTree;

         }

         //仅为非空树定义,从给定树中删去它的第i棵子树并连上一个空树,度数相同,并且返回删除的子树引用

         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;

         }

     }

}

 

上一篇:数据结构与算法(C#实现)系列---N叉树(一) 人气:15598
下一篇:C#中的代理(delegate) 人气:14939
浏览全部数据结构与算法(C#实现)的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐