|
-
September 25th, 1999, 05:02 PM
#1
Arrays
How do i delete items from a dynamic array? Is there an efficient way of manipulating dynamic arrays. I can use collection but that will slow my app. Any ideas? anyone?
-
September 26th, 1999, 09:44 AM
#2
Re: Arrays
Try writing yourself a vector class to wrap the array. Put error handling in an Add method to catch when you've exceeded array bounderies then redimension the array using the preserve keyword.
You can also monitor to see when it is necessary to shrink the array. Vectors are much faster than collections but you can't really delete entries in the middle of the vector.
To give you an idea here's some code out of "Hardcore Visual Basic" by Bruce McKinney:
property let Item(byval i as long, byval ItemA as Variant)
on error Goto FailLetItem
av(i)=ItemA
If i> iLast then iLast=1
Exit property
FailLetItem:
If i>UBound(av) then
Redim Preserve av(1 to i+cChunk) as Variant
resume
End if
Err.Raise Err.Number
End property
Where cChunk is a set amount by wich the array will expand each time its upper boundery is exceeded.
-
September 29th, 1999, 03:49 PM
#3
Re: Arrays
thanks for the info. i've decided to go with collections instead of dealing with efficiency pain myself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|