On Wed, 9 Feb 2011 22:04:58 -0500, Brad Stone <cocoa-...@softraph.com> said:
>I made this code to remove any duplicate words from a large group of text. 

>if ([resultArray indexOfObject:s] == NSNotFound)

There's the problem. Who knows how this is implemented? You could be searching 
the entire array one entry at a time all the way to the end for every single 
word (if the text goes, say, "fee fi fo fum fum fum fum fum..."). That's why 
the usual algorithm for this sort of thing involves a dictionary, not an array; 
access to a key in a dictionary is guaranteed fast because of hashing. 
Basically you're making a histogram, which is a well-solved problem. If order 
matters, use both the dictionary *and* some other storage to keep track of the 
words in the order in which they actually appear. m.

--
matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to