• 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: Vincent Habchi <email@hidden>
  • Date: Tue, 19 Jul 2011 16:36:37 +0200

> 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

  • Follow-Ups:
    • Re: Optimizing a loop
      • From: "Eric E. Dolecki" <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>)

  • Prev by Date: Re: Optimizing a loop
  • Next by Date: Re: Optimizing a loop
  • Previous by thread: Re: Optimizing a loop
  • Next by thread: Re: Optimizing a loop
  • Index(es):
    • Date
    • Thread