• 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 15:40:46 +0200

> Oops - I meant to say it's an NSMutableDictionary!
>
> What might a quick stubbed example of that be? Not sure I am following. How much speed would it generally gain?

Simple example. Init a NSMutableDictionary. For each string, compute a hash key as the sum of all chars composing it (in a short or int), divide it by 8 (that's quick). This way, all the words that differ by just one char being exchanged (metathesis), or look more or less the same, will get an identical hash code.

In your mutable dictionary, use the hash key as the key, the object being an NSMutableArray where you put all the strings that share the same hash key. Then use the contents of this NSMutableArray as proposals for your user. That should be really fast. Refine the process if you need more grain.

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>)

  • 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