ClassArrayList
Privateitems()
Privatesize
PrivateSubClass_Initialize
size=0
ReDimitems(1)
EndSub
PrivateSubClass_Terminate
items=null
EndSub
PublicFunctionAdd(ByValvalue)
If(size=Ubound(items))ThenEnsureCapacity((size+1))
items(size)=value
size=size+1
Add=size
EndFunction
PublicPropertyGetItem(index)
Item=items(index)
EndProperty
PublicPropertyLetItem(index,vObject)
items(index)=vObject
EndProperty
PropertyGetCount
Count=size
EndProperty
PublicPropertyGetCapacity()
Capacity=Ubound(items)
EndProperty
PublicPropertyLetCapacity(value)
If(value<>Ubound(items))Then
If(value<size)ThenErr.Rise6
If(value>0)Then
ReDimPreserveitems(value)
Else
ReDimPreserveitems(3)
EndIf
EndIf
EndProperty
PrivateSubEnsureCapacity(ByValmin)
If(Ubound(items)<min)Then
Dimnum1:num1=IIf((Ubound(items)=0),4,(Ubound(items)*2))
If(num1<min)Thennum1=min
Capacity=num1
EndIf
EndSub
PrivateFunctionIIf(j,r1,r2)
IF(j)Then
IIf=r1
Else
IIf=r2
EndIF
EndFunction
EndClass
示例:
Dimal:Setal=newArrayList
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)
Fori=0Toal.Count-1
w("Index"&i&":"&al.Item(i))
Next
w("Count:"&al.Count)
w("Capacity:"&al.Capacity)
Subw(o)
Response.Write(o&"<br/>")
EndSub