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.

No, that didn't fix it.

I did find something quite interesting, but I don't know if it's related. I made a simple loop that gets a few keys from the dictionary. The resulting string is:

Indexes 700 to 710
accessible
accessibly
accessing
accession
accessioned
accessioning
accessions
accessories
accessorise
accessorised
accessorises

The first line is hard coded, and the subsequent lines are the result of a for-next loop. Notice the spaces between the letters. What's interesting is that when I copy the same string variable to an editfield using code at runtime, the letters appear as expected - no spaces. If I select all of the text in the editfield, copy it to the clipboard, and paste it in Mail, I get exactly the same result. The first line has no spaces between letters, and the rest do. I tried copying and pasting one of the above words into my input box, but HasKey still returned false.

Encoding problem, maybe?  The source text file is encoded UTF-16.

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.

Do you mean to handle it just like a database handles itself? I understand that concept, but how do you do it?


Andrew Keller_______________________________________________
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>

Reply via email to