Use an NSMutableSet instead. That should have constant lookup time instead of 
linear (like an array usually is). 

Dave

Sent from my iPhone

On Mar 11, 2011, at 6:11 PM, Leonardo <[email protected]> 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];
>    }
> }
> 
> You understand well that the task works fast at the beginning, but it gets
> slower and slower at any word added to the uniqueWordsArray.
> What's the best way to do that?
> Should I use the internal SQLLite database? CoreData? Other?
> 
> 
> Regards
> -- Leonardo
> 
> 
> _______________________________________________
> 
> 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/davedelong%40me.com
> 
> This email sent to [email protected]
_______________________________________________

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