Re: Efficient searching of an NSArray of NSDictionary
Re: Efficient searching of an NSArray of NSDictionary
- Subject: Re: Efficient searching of an NSArray of NSDictionary
- From: Jens Alfke <email@hidden>
- Date: Tue, 29 Sep 2009 11:07:10 -0700
On Sep 29, 2009, at 7:38 AM, Pascal Harris wrote:
I have an application with an NSArray of NSDictionary (with 18 keys)
which
populates an NSTableView. I am concerned that my method of
accessing the
contents of my array are sub-optimal and I'm therefore seeking
advice from
the experts.
Is your concern based on an actual slowdown? Have you loaded up a big
data-set and measured the search time? Or do you know your algorithms
well enough to be able to predict really bad behavior (like O(n^2)
time) with large data?
If not, I would ignore this optimization until and unless it becomes
necessary. Modern CPUs are insanely fast.
If so, profile your code to see where the time is going; sometimes the
results are unintuitive.
Using predicates isn't likely to help any, because they're just a
higher-level way of doing the same kind of search you'd write by hand,
only a bit slower because they're interpreted. CoreData can in some
cases be faster if it can do the search at the underling SQL layer.
There are other ways you can change your data structures slightly and
get a speedup, such as keeping your arrays sorted and doing a binary
search.
—Jens_______________________________________________
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