• 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: Robert Martin <email@hidden>
  • Date: Tue, 29 May 2007 14:53:04 -0400

May not be directly relevant, but it's interesting: http:// ridiculousfish.com/blog/archives/2005/12/23/array/


On May 29, 2007, at 1:51 PM, Keith Duncan wrote:

I've searched google for benchmarks but I couldn't find any specific to what I'm looking for so I decided to do some benchmarking of my own. | was hoping someone could corroborate or contradict my results.

I'm iterating over a tree of objects but instead of iterating the tree multiple times I decided to iterate the tree once and put the nodes into an array. This allows me to check for the presence of various objects quickly, for the purposes of this discussion two objects are deemed to be equal if a pointer comparison is true.

Essentially what I'm looking for is the quickest way to determine if any of the objects stored in another array, are no longer present in the content array, that is the array derived from the content tree.

As far as I can see there are two NSArray methods of interest - containsObject: and -indexOfObjectIdenticalTo:, the documentation states that -containsObject: uses the NSObject protocol method - isEqual: to determine equality. However the docs are vague as to what the default implementation does stating instead that the implementation depends on the context.

As all I need is a simple pointer comparison - indexOfObjectIdenticalTo: seemed like a better option, however my tests indicated that the -containsObject: method was slightly faster!?

The tree I am iterating contains under 50 objects (it will, or rather might have to, contain many more - at which point speed will be essential, this really depends on the user so it isn't just premature optimisation on my part). Perhaps my results are not too indicative.

I was just curious as to whether someone else had any insight into which was a faster/more efficient way of accomplishing this?

- 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:
40frontiernet.net


This email sent to email@hidden


_______________________________________________

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>)

  • Prev by Date: Disabling items in NSTabView
  • Next by Date: Re: memory mgmt in convenience and accessor methods
  • Previous by thread: NSArray lookup, pointer comparison
  • Next by thread: Re: NSArray lookup, pointer comparison
  • Index(es):
    • Date
    • Thread