asp,vbscript二叉树排序源码
2011-03-18 18:09
344 查看
参考某人的js二叉树写的asp的二叉树,有问题欢迎提出
Class TreeSort Private LeftNode Private MiddleNode Private RightNode Private Sub Class_Initialize() Set LeftNode = Nothing Set RightNode = Nothing MiddleNode = Null End Sub Private Sub Class_Terminate() Set LeftNode = Nothing Set RightNode = Nothing MiddleNode = Null End Sub Public Sub Add(ByVal Value) If IsNull(Node) Then Node = Value Exit Sub End If Dim NewNode Set NewNode = New TreeSort NewNode.Node = Value If Node >= Value Then If Left Is Nothing Then Set Left = NewNode Else Left.Add(Value) End If Else If Right Is Nothing Then Set Right = NewNode Else Right.Add(Value) End If End If Set NewNode = Nothing End Sub Public Function Print() If Not(Left Is Nothing) Then Left.Print() End If PrintArray(Node) If Not(Right Is Nothing) Then Right.Print() End If End Function Public Property Set Left(ByVal Object) Set LeftNode = Object End Property Public Property Get Left() Set Left = LeftNode End Property Public Property Let Node(ByVal Value) MiddleNode = Value End Property Public Property Get Node() Node = MiddleNode End Property Public Property Set Right(ByVal Object) Set RightNode = Object End Property Public Property Get Right() Set Right = RightNode End Property End Class Dim newArrArray newArrArray=Array() Sub PrintArray(ByVal newValue) Dim arrNewArray(),i ReDim arrNewArray(UBound(newArrArray)+1) For i=0 To UBound(newArrArray) arrNewArray(i) = newArrArray(i) Next arrNewArray(i) = newValue newArrArray = arrNewArray End Sub Function TSort(ByVal arrSortArray) Dim TCLS,i Set TCLS = New TreeSort For i = 0 To UBound(arrSortArray) TCLS.Add(arrSortArray(i)) Next TCLS.Print() TSort = newArrArray End Function arr=Array(1,2,5,3,2,6,3,2) arr=TSort(arr) Document.Write(Join(arr,","))
相关文章推荐
- Asp.Net大型项目实践(4)-用NHibernate保存和查询我们的业务领域对象之分页与排序(附源码)
- Asp.Net大型项目实践(4)-用NHibernate保存和查询我们的业务领域对象之分页与排序(附源码)
- Asp.net源码本周更新(免费下载)—4月10日开始
- ASP 五年总结精华源码
- ASP.NET Core 2.1 源码学习之 Options[1]:Configure
- 【网站国际化必备】Asp.Net MVC 集成Paypal(贝宝)快速结账 支付接口 ,附源码demo
- asp.net网络书店网站源码
- 源码展示:ASP.NET 数据访问类
- Asp.net web Api源码分析-HttpResponseMessage
- 日历控件源码开放--适用于ASP.NET 1.1
- 【数据结构与算法】内部排序之二:冒泡排序和选择排序(改进优化,附完整源码)
- 各种排序方法源码及复杂度分析(一)
- ASP.NET中数据库备份的源码
- 二叉树排序树的基本操作
- ASP_NET_MVC3_请求处理流程(2) MVC源码分析
- Asp.Net Ajax In Action图书源码
- Asp.Net GridView點擊標題排序方法
- Asp.net MVC源码分析 -- 获取ModelBinder的优先级
- asp.net实现非常实用的自定义页面基类(附源码)
- 附源码:PHP实现查询汉字笔画、笔画排序