Create a sorted secondary array with your most searched item. Then you can
use a binary seach to find what you want quicky.
Example;
'-- Your struct array
mystruct(0).name="Mark"
mystruct(0).Id = 152437
mystruct(1).name="Bob"
mystruct(1).Id = 23437
mystruct(2).name="Chuck"
mystruct(2).Id = 37674
mystruct(3).name="Mr Cool"
mystruct(3).Id = 17222
mystruct(4).name="Terry"
mystruct(4).Id = 7865
mystruct(5).name="Dufuss"
mystruct(5).Id = 67543
'-- Sorted Secondary Array:
Dim sortedArray(5) as Integer
'-- These are sorted by name
sortedArray(0) = 1 '-- Bob
sortedArray(1)=2 '-- Chuck
sortedArray(2)=5 '-- Dufuss
sortedArray(3)=0 '-- Mark
sortedArray(4)=3 '-- Mr Cool
sortedArray(5)=4 '-- Terry
Then use a binary search on this array and not you struct array. You can
also create another sorted array for the id's if you wish.
"Stuart" <st****@stu.org.uk> wrote in message
news:bp*************@ID-17980.news.uni-berlin.de...
I am converting a VB6 App.
In the VB6 app, I have a Type structure of about 30 elements (mixture of
booleans, integers, strings and some doubles), in an array of say 20 to
100+ records.
The size of the array doesn't change that frequently, so the speed of
inserting and removing records is not that important. However, the
speed of finding, and read/writing of the elements is very import.
Needs to be thread safe too.
Am I best sticking with setting up a Structure, and attaching it to an
array, manually sizing it, and recursively searching though it, or is
there a better alternative?
Thanks,
Stuart.