Re: Optimizing a loop
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