Muthu Ram
September 25th, 1999, 05:02 PM
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?
|
Click to See Complete Forum and Search --> : Arrays Muthu Ram September 25th, 1999, 05:02 PM 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? Mikesc September 26th, 1999, 09:44 AM 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. Muthu Ram September 29th, 1999, 03:49 PM thanks for the info. i've decided to go with collections instead of dealing with efficiency pain myself. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |