• 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: Finding object array index when iterating through array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding object array index when iterating through array


  • Subject: Re: Finding object array index when iterating through array
  • From: Daniel Vollmer <email@hidden>
  • Date: Thu, 08 Mar 2012 16:11:14 +0100

On 7 Mar 2012, at 12:09, John Maisey wrote:

> Hi,
>
> If the items are unique, how about:
>
> [array indexOfObject:object];

Congratulations, you have just (depending on NSArray-implementation details) "improved" your loop from from O(N) to O(N^2). Don't do this.

> Using a counter is likely be faster though.

Correct.

	Daniel.
_______________________________________________

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


References: 
 >Re: Finding object array index when iterating through array (From: John Maisey <email@hidden>)

  • Prev by Date: Re: NSOpenPanel may not respond to setDirectoryURL?
  • Next by Date: ivar access during -finalize
  • Previous by thread: Re: Finding object array index when iterating through array
  • Next by thread: UIKit-additions and class references
  • Index(es):
    • Date
    • Thread