Re: Abbreviated-Keyword Dictionary Search possible?
Re: Abbreviated-Keyword Dictionary Search possible?
- Subject: Re: Abbreviated-Keyword Dictionary Search possible?
- From: Allan Odgaard <email@hidden>
- Date: Wed, 21 Apr 2004 03:35:53 +0200
On 21. Apr 2004, at 0:35, Frederick C. Lee wrote:
I'm developing a NSDictionary object that contains Countries as keys,
and associated NSArrays as their respective values. Rather than
having to type the entire country name, I would like to merely type
the minimum unique part and have it search & retrieve the data from
the NSDictionary.
A dictionary works by calculating a hash-code for the key and use that
as index into the value array. Given a partial key, there is no way it
can find the value.
So you'd need to keep a (sorted) array of all countries and (binary)
search that for the closest match, which you then use as the key (or
store the value in the same array).
You can also device your own structure like a ternary search tree,
which is very useful for these kinds of (partial) lookups.
** Cocoa FAQ: <
http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.