Thank you so much to everybody.
I am now using NSSet and it works so fast!

Regards
-- Leonardo


> Da: Conrad Shultz <[email protected]>
> Data: Fri, 11 Mar 2011 18:20:05 -0800
> A: Leonardo <[email protected]>
> Cc: <[email protected]>
> Oggetto: Re: Unique strings array
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 3/11/11 6:11 PM, Leonardo wrote:
>> Hi,
>> I have to extract a list of "unique words" from an array of hundred
>> thousands words and put them into an uniqueWordsArray. I already succeeded
>> but the task is very very slow because I don't index the uniqueWordsArray.
>> So my question is: how to index the array and get a fast check?
>> Actually I do:
>> 
>> for(NSString *aWord in wordsArray){
>>    if([uniqueWordsArray  containsObject:aWord] == NO){
>>         [uniqueWordsArray  addObject:aWord];
>>     }
>> }
> 
> Have you considered NSSet?  I think that
> 
> + (id)setWithArray:(NSArray *)array
> 
> should do what you want in one line.  It presumably is highly optimized
> internally.
> 
> (Of course, if you need your results indexed as in an array, you will
> need to then transform the set into an array and sort as needed.)
> 
> - -- 
> Conrad Shultz
> 
> Synthetiq Solutions
> www.synthetiqsolutions.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iD8DBQFNethVaOlrz5+0JdURAhvPAJoDSWmRCgLkJUJH/P8voY1VILkJnACdHtj+
> wdlNv8gO4leN+ZTU9s6CvjI=
> =BiGJ
> -----END PGP SIGNATURE-----


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to