• 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: Optimizing a loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimizing a loop


  • Subject: Re: Optimizing a loop
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Tue, 19 Jul 2011 10:48:56 -0400

I think I see what you're onto here now. So I might only have about 30 or so
keys to search through instead of all 1,777 items, and then just grab an
array (or probably a dictionary) of stuff out of that to search on...
resulting in a lot less searching to hopefully get to a potential match.

a song search for "Cold Wind to Valhalla" ... char count of 21, look in the
dictionary for key of int 21 (or close), and check it (probably another
dictionary) for it's key of the title to get the MPMediaItem.


  Google Voice: (508) 656-0622
  Twitter: eric_dolecki      XBoxLive: edolecki      PSN: eric_dolecki
  http://blog.ericd.net



On Tue, Jul 19, 2011 at 10:36 AM, Vincent Habchi <email@hidden> wrote:

> > Thanks. The distance is computed because the entry string is dynamic and
> it's providing a distance between the title of the song and what was entered
> as text. So I can't pre-compute that data and stuff into a dictionary. Each
> time the method is called, the stringValue will be different.
>
> Yep, I understand.
>
> What you do is that for each entry string you compute the hash key (which
> is fast, as it is only a sum of chars), and you select the key which is the
> nearest to your dynamic key. You can do that on the fly.
>
> Somehow, if you want to compare only strings of the same length, you have
> to rely on a two level dictionary, or make your key special (e.g. the upper
> byte contains the string length, the lower bytes are the hash key).
>
> Vincent
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Optimizing a loop (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Optimizing a loop (From: Vincent Habchi <email@hidden>)
 >Re: Optimizing a loop (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Optimizing a loop (From: Vincent Habchi <email@hidden>)
 >Re: Optimizing a loop (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Optimizing a loop (From: Vincent Habchi <email@hidden>)
 >Re: Optimizing a loop (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Optimizing a loop (From: Vincent Habchi <email@hidden>)

  • Prev by Date: Re: Optimizing a loop
  • Next by Date: Re: Why are these objects still faults?
  • Previous by thread: Re: Optimizing a loop
  • Next by thread: Re : Optimizing a loop
  • Index(es):
    • Date
    • Thread