• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArray lookup, pointer comparison
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSArray lookup, pointer comparison (From: Keith Duncan <email@hidden>)
 >Re: NSArray lookup, pointer comparison (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Bindings on custom objects
  • Next by Date: Re: Weird problem involving memory management and global variable
  • Previous by thread: Re: NSArray lookup, pointer comparison
  • Next by thread: Re: NSArray lookup, pointer comparison
  • Index(es):
    • Date
    • Thread