• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Abbreviated-Keyword Dictionary Search possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Abbreviated-Keyword Dictionary Search possible? (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Re: [little OT] Licensing/Implementing in Cocoa/Obj-C
  • Next by Date: Re: Locking from within an enumerator
  • Previous by thread: Abbreviated-Keyword Dictionary Search possible?
  • Next by thread: Locking from within an enumerator
  • Index(es):
    • Date
    • Thread