On Feb 15, 2007, at 6:32 PM, Marc Zeedar wrote:

Then, to check for the existence, during the display methods I use If d.KeyExists theList(i) Then ...

My question is - with potentially 10K selection lines, is this an abuse of the dictionary class? Will it be faster than parsing an array of the same data?

This is exactly what dictionaries are for!

As a test once, I loaded 200K spelling words in a dictionary and checked a user's typing in an editfield for spelling errors. Turned out my code for retrieving the last full word typed (not as simple as it sounds) took much longer than the superfast dictionary look- up. I had to get that optimized, but eventually I had it so the user could type full speed without the live spelling checking slowing things down. Pretty cool! I just love dictionaries.

As an aside, don't be afraid to make a dictionary subclass, in which the lookup returns the exact type you're looking for, so you don't have to keep casting the damn variants all the time.

I've also used a dictionary as a Set type, by wrapping the dictionary with some set operations. You just add the set's values as keys to the dictionary, and ignore the value it's mapped to. Intersection and whatnot are slow (but so what?), but membership testing is fast as blazes.

I, too, use dictionaries all the time. Probably a third of my classes use a dictionary for one thing or another.

Regards,

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Ruby/Rails, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to