Class ArrayList Private items() Private size PrivateSub Class_Initialize size =0 ReDim items(1) End Sub PrivateSub Class_Terminate items =null End Sub PublicFunction Add(ByVal value) If (size =Ubound(items)) Then EnsureCapacity((size +1)) items(size) = value size = size +1 Add = size End Function PublicPropertyGet Item(index) Item = items(index) End Property PublicPropertyLet Item(index, vObject) items(index) = vObject End Property PropertyGet Count Count = size End Property PublicPropertyGet Capacity() Capacity =Ubound(items) End Property PublicPropertyLet Capacity(value) If (value <>Ubound(items)) Then If (value < size) Then Err.Rise 6 If (value >0) Then ReDim Preserve items(value) Else ReDim Preserve items(3) EndIf EndIf End Property PrivateSub EnsureCapacity(ByVal min) If (Ubound(items) < min) Then Dim num1 : num1 = IIf((Ubound(items) =0), 4, (Ubound(items) *2)) If (num1 < min) Then num1 = min Capacity = num1 EndIf End Sub PrivateFunction IIf(j, r1, r2) IF (j) Then IIf = r1 Else IIf = r2 EndIF End Function End Class 示例: Dim al : Set al =new ArrayList al.Add(1) al.Add(2) al.Add(3) al.Add(4) al.Add(5) al.Add(6) al.Add(7) al.Add(8) al.Add(9) al.Add(10) For i =0To al.Count -1 w("Index"& i &": "& al.Item(i)) Next w("Count: "& al.Count) w("Capacity: "& al.Capacity) Sub w(o) Response.Write(o &"<br />") End Sub
posted on
2006-05-31 21:23jayu
阅读(359)
评论(0)
编辑收藏举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步