From: Charles Yeomans <[EMAIL PROTECTED]>
Date: Sat, 8 Apr 2006 14:52:18 -0400
On Apr 8, 2006, at 11:56 AM, [EMAIL PROTECTED] wrote:
If it were me, I'd just drag the text file directly into the
project. Then at app startup (or better yet, the first time you
need to look up a word), split the file on its end-of-line
delimiter and stuff the words into a Dictionary object (as keys,
with a dummy value like True).
Stuffing the dictionary with 3.9 MB of data might take a second or
so, but then lookup (using Dictionary.HasKey) will be blazingly
fast. Also, since you know ahead of time how many words you'll be
stuffing, you can make the stuffing go faster by pre-sizing the
dictionary (i.e., assign a suitably large BinCount before you
start loading in values).
Okay, I've got the dictionary loaded, but HasKey is always
returning false. Any Ideas?
BinCount of the dictionary is 65521, Count is 177741, loading it
takes 2 seconds on a dual 1 GHz G4, and HasKey returns an answer
virtually instantaneously.
Your BinCount is too small. Set it to 3*177741. If that fixes your
problem, then you have found a problem with the Dictionary
implementation.
You might also consider an alternative implementation. Load the word
list into an array, sort it, and write the result out to a file.
Then you can load the sorted list at runtime and use binary search to
look up a word. This will require either 18 or 19 string comparisons
for each lookup. It may be slower than a Dictionary on average, but
it's guaranteed to be faster in the worst case, and it uses less
memory.
My ElfDataDictionary doesn't have any known bugs (except for method
name conflict bug caused by REALbasic, but I worked around that one
already).
It's available for all RB supported platforms. It's got .HasKey also.
It's also a lot faster than RB's dictionary.
It's case sensitive though, so it might not be what you are looking
for. The original poster got alone fine with RB's dictionary's case-
insensitiveness, which might be because he relied on it that way.
--
http://elfdata.com/plugin/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>