frothytoad
Technical User
Hello. I could use some advice from people who have faced this problem already.
For an application I am building I need an autocomplete combo box. Naively, I went and coded one, and it worked fine, but it used a linear search. When I realized that I might have many tens or hundreds of thousands of entries (or more), I went back and put in a binary search. No problem. But...
In order to add and remove new items efficiently, I use a collection to store the items in the list. But, as you may have already guessed, this has some drawbacks, which leads me to my two questions:
1) Is there a way to insert a new element into the middle of an array? I.e. if I have an array with 5000 entries, can I put one in between 2033 and 2034 without redimming, looping from 5000 to 2034, shifting all values, and then adding the new value?
2) Is there a fast way to add large numbers of things to a collection? It takes about 8-10 seconds to add ~6000 items, which is too long.
I had thought about just referencing into the recordset that provides the data and not storing the values anywhere else, but I cannot be sure that my recordset is sorted, and it does not seem that ADO provides a sort method (or did I just miss it???). Also, the needs for displaying info in the combo box make an unsort data source unacceptable.
Lots of questions, I realize, but even a few answers would be appreciated.
Thanks!
-- Jeff
For an application I am building I need an autocomplete combo box. Naively, I went and coded one, and it worked fine, but it used a linear search. When I realized that I might have many tens or hundreds of thousands of entries (or more), I went back and put in a binary search. No problem. But...
In order to add and remove new items efficiently, I use a collection to store the items in the list. But, as you may have already guessed, this has some drawbacks, which leads me to my two questions:
1) Is there a way to insert a new element into the middle of an array? I.e. if I have an array with 5000 entries, can I put one in between 2033 and 2034 without redimming, looping from 5000 to 2034, shifting all values, and then adding the new value?
2) Is there a fast way to add large numbers of things to a collection? It takes about 8-10 seconds to add ~6000 items, which is too long.
I had thought about just referencing into the recordset that provides the data and not storing the values anywhere else, but I cannot be sure that my recordset is sorted, and it does not seem that ADO provides a sort method (or did I just miss it???). Also, the needs for displaying info in the combo box make an unsort data source unacceptable.
Lots of questions, I realize, but even a few answers would be appreciated.
Thanks!
-- Jeff