The array class _vbs in the VBS ARRAYLIST class VBS
Source: Internet
Author: User
Class ArrayList
Private items ()
Private size
Private Sub Class_Initialize
Size = 0
ReDim items (1)
End Sub
Private Sub Class_Terminate
Items = null
End Sub
Public Function Add (ByVal value)
If (size = Ubound (items)) Then ensurecapacity ((size + 1))
Items (size) = value
size = size + 1
ADD = Size
End Function
Public Property Get Item (Index)
Item = Items (index)
End Property
Public Property Let Item (Index, Vobject)
Items (Index) = Vobject
End Property
Property Get Count
Count = Size
End Property
Public Property Get Capacity ()
Capacity = Ubound (items)
End Property
Public Property Let 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)
End If
End If
End Property
Private Sub 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
End If
End Sub
Private Function IIf (J, R1, R2)
IF (j) Then
IIf = R1
Else
IIf = R2
End IF
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.