Click to See Complete Forum and Search --> : Most efficient way of building a dynamic array?


cusimar9
11-24-2006, 04:08 AM
Lets say I want to generate N values of something, whats the best way of storing them in an array?

I can think of a few main ways:

1. Declare a dynamic array and 'redim preserve' it for every new item (slowest)
2. Declare a massive array and 'redim preserve' it at the end to the correct number of items
3. Declare a dictionary object and only add the items you need

I've just done some basic testing and the dictionary object seems to be the fastest as no resizing of the array is necessary...

Is this the fastest way to do it?