Re: Unique strings array
Re: Unique strings array
- Subject: Re: Unique strings array
- From: Leonardo <email@hidden>
- Date: Sat, 12 Mar 2011 14:50:02 +0100
- Thread-topic: Unique strings array
Thank you so much to everybody.
I am now using NSSet and it works so fast!
Regards
-- Leonardo
> Da: Conrad Shultz <email@hidden>
> Data: Fri, 11 Mar 2011 18:20:05 -0800
> A: Leonardo <email@hidden>
> Cc: <email@hidden>
> 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@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