Re: NSArray lookup, pointer comparison
Re: NSArray lookup, pointer comparison
- Subject: Re: NSArray lookup, pointer comparison
- From: Keith Duncan <email@hidden>
- Date: Wed, 30 May 2007 00:47:21 +0100
Andrew Farmer wrote:
Use an NSSet instead of an array? NSSet has a containsObject:
method, which should be much faster than scanning over an array.
That's a good idea, I rarely find a need for an NSSet, except when
working with CoreData, so it isn't usually something I think of. I'll
change my recursive Tree->Array method to use NSSet instead and see
how that affects the performance.
Uli Kusterer wrote:
What kind of a tree is this? Sorted trees (like binary trees, or
red/black trees or whatever) have much better performance than the
typical linear array search, because due to the sorting a well-
balanced tree can eliminate half the nodes each time it decides
which of two branches to go down.
You're right this is a sorted tree, I didn't think about attempting
to utilise the sort information to decide which of the child nodes is
actually worth checking. I'm not sure what the algorithm will look
like but I'll try to implement one tomorrow.
Thanks for the answers they were both really helpful.
- Keith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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